Skip to content

Commit 52ecb88

Browse files
committed
[stdlib] Enable Dicitionary validation test on non-Darwin platforms
1 parent fbc76af commit 52ecb88

File tree

1 file changed

+36
-15
lines changed

1 file changed

+36
-15
lines changed

validation-test/stdlib/Dictionary.swift

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,30 @@
22
// RUN: mkdir -p %t
33
//
44
// RUN: %S/../../utils/gyb %s -o %t/main.swift
5-
// RUN: %target-clang -fobjc-arc %S/Inputs/SlurpFastEnumeration/SlurpFastEnumeration.m -c -o %t/SlurpFastEnumeration.o
6-
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %S/Inputs/DictionaryKeyValueTypesObjC.swift %t/main.swift -I %S/Inputs/SlurpFastEnumeration/ -Xlinker %t/SlurpFastEnumeration.o -o %t/Dictionary -Xfrontend -disable-access-control
5+
// RUN: if [ %target-runtime == "objc" ]; then \
6+
// RUN: %target-clang -fobjc-arc %S/Inputs/SlurpFastEnumeration/SlurpFastEnumeration.m -c -o %t/SlurpFastEnumeration.o; \
7+
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %S/Inputs/DictionaryKeyValueTypesObjC.swift %t/main.swift -I %S/Inputs/SlurpFastEnumeration/ -Xlinker %t/SlurpFastEnumeration.o -o %t/Dictionary -Xfrontend -disable-access-control; \
8+
// RUN: else \
9+
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift %S/Inputs/DictionaryKeyValueTypes.swift %t/main.swift -o %t/Dictionary -Xfrontend -disable-access-control -Xfrontend -disable-objc-attr-requires-foundation-module; \
10+
// RUN: fi
711
//
812
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-run %t/Dictionary
913
// REQUIRES: executable_test
1014

11-
// XFAIL: linux
12-
15+
#if os(OSX) || os(iOS) || os(tvOS) || os(watchOS)
1316
import Darwin
17+
#else
18+
import Glibc
19+
#endif
20+
1421
import StdlibUnittest
1522
import StdlibCollectionUnittest
1623

1724

25+
#if _runtime(_ObjC)
1826
import Foundation
1927
import StdlibUnittestFoundationExtras
28+
#endif
2029

2130
// Check that the generic parameters are called 'Key' and 'Value'.
2231
protocol TestProtocol1 {}
@@ -1142,6 +1151,7 @@ DictionaryTestSuite.test("init(dictionaryLiteral:)") {
11421151
}
11431152
}
11441153

1154+
#if _runtime(_ObjC)
11451155
//===---
11461156
// NSDictionary -> Dictionary bridging tests.
11471157
//===---
@@ -3405,6 +3415,7 @@ DictionaryTestSuite.test("DictionaryBridgeFromObjectiveCConditional") {
34053415
assert(false)
34063416
}
34073417
}
3418+
#endif // _runtime(_ObjC)
34083419

34093420
//===---
34103421
// Tests for APIs implemented strictly based on public interface. We only need
@@ -3421,6 +3432,18 @@ func getDerivedAPIsDictionary() -> Dictionary<Int, Int> {
34213432

34223433
var DictionaryDerivedAPIs = TestSuite("DictionaryDerivedAPIs")
34233434

3435+
DictionaryDerivedAPIs.test("isEmpty") {
3436+
do {
3437+
var empty = Dictionary<Int, Int>()
3438+
expectTrue(empty.isEmpty)
3439+
}
3440+
do {
3441+
var d = getDerivedAPIsDictionary()
3442+
expectFalse(d.isEmpty)
3443+
}
3444+
}
3445+
3446+
#if _runtime(_ObjC)
34243447
@objc
34253448
class MockDictionaryWithCustomCount : NSDictionary {
34263449
init(count: Int) {
@@ -3473,17 +3496,6 @@ func getMockDictionaryWithCustomCount(count: Int)
34733496
return MockDictionaryWithCustomCount(count: count) as Dictionary
34743497
}
34753498

3476-
DictionaryDerivedAPIs.test("isEmpty") {
3477-
do {
3478-
var empty = Dictionary<Int, Int>()
3479-
expectTrue(empty.isEmpty)
3480-
}
3481-
do {
3482-
var d = getDerivedAPIsDictionary()
3483-
expectFalse(d.isEmpty)
3484-
}
3485-
}
3486-
34873499
func callGenericIsEmpty<C : Collection>(_ collection: C) -> Bool {
34883500
return collection.isEmpty
34893501
}
@@ -3515,6 +3527,7 @@ DictionaryDerivedAPIs.test("isEmpty/ImplementationIsCustomized") {
35153527
expectEqual(1, MockDictionaryWithCustomCount.timesCountWasCalled)
35163528
}
35173529
}
3530+
#endif // _runtime(_ObjC)
35183531

35193532
DictionaryDerivedAPIs.test("keys") {
35203533
do {
@@ -3547,6 +3560,7 @@ DictionaryDerivedAPIs.test("values") {
35473560
}
35483561
}
35493562

3563+
#if _runtime(_ObjC)
35503564
var ObjCThunks = TestSuite("ObjCThunks")
35513565

35523566
class ObjCThunksHelper : NSObject {
@@ -3690,6 +3704,7 @@ ObjCThunks.test("Dictionary/Return") {
36903704
expectEqual(0, TestBridgedValueTy.bridgeOperations)
36913705
}
36923706
}
3707+
#endif // _runtime(_ObjC)
36933708

36943709
//===---
36953710
// Check that iterators traverse a snapshot of the collection.
@@ -3817,6 +3832,7 @@ DictionaryTestSuite.test("misc") {
38173832
}
38183833
}
38193834

3835+
#if _runtime(_ObjC)
38203836
DictionaryTestSuite.test("dropsBridgedCache") {
38213837
// rdar://problem/18544533
38223838
// Previously this code would segfault due to a double free in the Dictionary
@@ -3856,6 +3872,7 @@ DictionaryTestSuite.test("getObjects:andKeys:") {
38563872
expectEqual([2, 1] as [NSNumber], Array(keys))
38573873
expectEqual(["two", "one"] as [NSString], Array(values))
38583874
}
3875+
#endif
38593876

38603877
DictionaryTestSuite.test("popFirst") {
38613878
// Empty
@@ -3904,12 +3921,16 @@ DictionaryTestSuite.test("removeAt") {
39043921

39053922
DictionaryTestSuite.setUp {
39063923
resetLeaksOfDictionaryKeysValues()
3924+
#if _runtime(_ObjC)
39073925
resetLeaksOfObjCDictionaryKeysValues()
3926+
#endif
39083927
}
39093928

39103929
DictionaryTestSuite.tearDown {
39113930
expectNoLeaksOfDictionaryKeysValues()
3931+
#if _runtime(_ObjC)
39123932
expectNoLeaksOfObjCDictionaryKeysValues()
3933+
#endif
39133934
}
39143935

39153936
runAllTests()

0 commit comments

Comments
 (0)