Skip to content

Test and Fix: subset and superset for empty character set #6000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 1, 2016

Conversation

MuhammadAnnaqeeb
Copy link
Contributor

1- add tests for subset and superset for empty character set
2- fix runtime crash of

CharacterSet(charactersIn: "ab").isSuperset(of: CharacterSet())

3- fix return value of

CharacterSet().isSuperset(of: CharacterSet())

expected value is true, currently returned value is false

While the Set has a test for empty set being subset of any other set at https://github.com/apple/swift/blob/e941da319598e71de5169fcd2cc625bd7600fb94/validation-test/stdlib/Set.swift#L2724 , Character Set does not have that test.

Also on Swift 3.0 and Swift 3.0.1, this code crashes during execution:
```
import Foundation
CharacterSet( charactersIn:"abc" ).isSuperset(of:  "")
```
without any failing tests; So this test fails if bug persists.
This Fixes that this code crashes during running:
```
import Foundation
CharacterSet( charactersIn:"abc" ).isSuperset(of:  "")
```
add test to assure runtime result of  empty set is subset of itself and superset of itself.

currently running on swift 3.0  returns false instead of expected true in the following code:
```
import Foundation
CharacterSet().isSuperset(of: CharacterSet())
```
@MuhammadAnnaqeeb
Copy link
Contributor Author

@swift-ci Please smoke test

@gparker42
Copy link
Contributor

Good catch. Can you add tests for the two false comparisons? (emptySet.isSuperset(of: immutableSet) and immutableSet.isSubset(of: emptySet))

@MuhammadAnnaqeeb
Copy link
Contributor Author

Thank you for your kind words.

@gparker42
Copy link
Contributor

@swift-ci Please smoke test

@gparker42 gparker42 merged commit e41a29a into swiftlang:master Dec 1, 2016
@jrose-apple
Copy link
Contributor

I'm not sure this is the right fix. Why would just this one API be broken? cc @phausler

@phausler
Copy link
Contributor

phausler commented Dec 1, 2016

I would guess this is not the only one broken here; most likely there are other cases that will fail too - my guess is actually it has to do with the secondary character set being passed across. So formUnionWithCharacterSet: or formIntersectionWithCharacterSet: might be broken too

@gparker42
Copy link
Contributor

The new test is also failing (runtime segfault) on the resilience bot. Did it uncover a resilience bug?

@gparker42
Copy link
Contributor

New test also segfaulted on watchOS simulator. I assume we have unresolved CharacterSet bugs somewhere. I'll revert this change and file bug reports for now.

@gparker42
Copy link
Contributor

gparker42 commented Dec 2, 2016

Filed rdar://29474937 for the test segfault. We'll revisit this once the bug is fixed.

@gparker42
Copy link
Contributor

Filed https://bugs.swift.org/browse/SR-3311 for the incorrect empty set behavior that this change was trying to fix. @jrose-apple and @phausler, if you suspect other empty set problems then please follow up there.

@MuhammadAnnaqeeb
Copy link
Contributor Author

I added tests for the resilience bug, so as to force the bug to appear in every testing causing runtime error. I also added tests for 3 other functions : isStrictSubset() and isStrictSuperset() and equality operator . Current file is at : https://github.com/MuhammadAnnaqeeb/swift/blob/master/test/stdlib/TestCharacterSet.swift Please reopen this Pull Request just for enough period to run tests. I only want to see if the tests would now constantly fails.

@jrose-apple
Copy link
Contributor

I don't think we can re-open a PR that was merged and then reverted. Can you make a new one?

@MuhammadAnnaqeeb
Copy link
Contributor Author

OK, I will open another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants