Skip to content

Commit 0f4c1cd

Browse files
committed
[stdlib] Fix unit tests for Set.Sequence methods
Really test the Sequence variants of set algebra and cover the same cases as Set.Set.
1 parent 475c209 commit 0f4c1cd

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

validation-test/stdlib/Set.swift

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2868,10 +2868,13 @@ SetTestSuite.test("isSubsetOf.Set.Set") {
28682868
}
28692869

28702870
SetTestSuite.test("isSubsetOf.Set.Sequence") {
2871-
let s1 = Set([1010, 2020, 3030, 4040, 5050, 6060])
2872-
expectTrue(Set<Int>().isSubset(of: s1))
2873-
expectFalse(s1.isSubset(of: Set<Int>()))
2874-
expectTrue(s1.isSubset(of: s1))
2871+
let s1 = Set([1010, 2020, 3030])
2872+
expectTrue(Set<Int>().isSubset(of: [1010]))
2873+
expectFalse(s1.isSubset(of: []))
2874+
expectTrue(Set<Int>().isSubset(of: []))
2875+
expectTrue(s1.isSubset(of: [1010, 2020, 3030]))
2876+
expectFalse(s1.isSubset(of: [1010, 2020]))
2877+
expectTrue(s1.isSubset(of: [1010, 2020, 3030, 4040]))
28752878
}
28762879

28772880
SetTestSuite.test("isStrictSubsetOf.Set.Set") {
@@ -2886,10 +2889,13 @@ SetTestSuite.test("isStrictSubsetOf.Set.Set") {
28862889
}
28872890

28882891
SetTestSuite.test("isStrictSubsetOf.Set.Sequence") {
2889-
let s1 = Set([1010, 2020, 3030, 4040, 5050, 6060])
2890-
expectTrue(Set<Int>().isStrictSubset(of: s1))
2891-
expectFalse(s1.isStrictSubset(of: Set<Int>()))
2892-
expectFalse(s1.isStrictSubset(of: s1))
2892+
let s1 = Set([1010, 2020, 3030])
2893+
expectTrue(Set<Int>().isStrictSubset(of: [1010]))
2894+
expectFalse(s1.isStrictSubset(of: []))
2895+
expectFalse(Set<Int>().isStrictSubset(of: []))
2896+
expectFalse(s1.isStrictSubset(of: [1010, 2020, 3030]))
2897+
expectFalse(s1.isStrictSubset(of: [1010, 2020]))
2898+
expectTrue(s1.isStrictSubset(of: [1010, 2020, 3030, 4040]))
28932899
}
28942900

28952901
SetTestSuite.test("isSupersetOf.Set.Set") {
@@ -2904,13 +2910,13 @@ SetTestSuite.test("isSupersetOf.Set.Set") {
29042910
}
29052911

29062912
SetTestSuite.test("isSupersetOf.Set.Sequence") {
2907-
let s1 = Set([1010, 2020, 3030, 4040, 5050, 6060])
2908-
let s2 = AnySequence([1010, 2020, 3030])
2913+
let s1 = Set([1010, 2020, 3030])
29092914
expectTrue(s1.isSuperset(of: Set<Int>()))
2910-
expectFalse(Set<Int>().isSuperset(of: s1))
2911-
expectTrue(s1.isSuperset(of: s1))
2912-
expectTrue(s1.isSuperset(of: s2))
2913-
expectFalse(Set<Int>().isSuperset(of: s1))
2915+
expectFalse(Set<Int>().isSuperset(of: [1010]))
2916+
expectTrue(Set<Int>().isSuperset(of: []))
2917+
expectTrue(s1.isSuperset(of: [1010, 2020, 3030]))
2918+
expectTrue(s1.isSuperset(of: [1010, 2020]))
2919+
expectFalse(s1.isSuperset(of: [1010, 2020, 3030, 4040]))
29142920
}
29152921

29162922
SetTestSuite.test("isStrictSuperset.Set.Set") {
@@ -2924,13 +2930,14 @@ SetTestSuite.test("isStrictSuperset.Set.Set") {
29242930
expectFalse(s2.isStrictSuperset(of: s1))
29252931
}
29262932

2927-
SetTestSuite.test("strictSuperset.Set.Sequence") {
2928-
let s1 = Set([1010, 2020, 3030, 4040, 5050, 6060])
2929-
let s2 = AnySequence([1010, 2020, 3030])
2930-
expectTrue(s1.isStrictSuperset(of: Set<Int>()))
2931-
expectFalse(Set<Int>().isStrictSuperset(of: s1))
2932-
expectFalse(s1.isStrictSuperset(of: s1))
2933-
expectTrue(s1.isStrictSuperset(of: s2))
2933+
SetTestSuite.test("isStrictSuperset.Set.Sequence") {
2934+
let s1 = Set([1010, 2020, 3030])
2935+
expectTrue(s1.isStrictSuperset(of: []))
2936+
expectFalse(Set<Int>().isStrictSuperset(of: [1010]))
2937+
expectFalse(Set<Int>().isStrictSuperset(of: []))
2938+
expectFalse(s1.isStrictSuperset(of: [1010, 2020, 3030]))
2939+
expectTrue(s1.isStrictSuperset(of: [1010, 2020]))
2940+
expectFalse(s1.isStrictSuperset(of: [1010, 2020, 3030, 4040]))
29342941
}
29352942

29362943
SetTestSuite.test("Equatable.Native.Native") {

0 commit comments

Comments
 (0)