2
2
// RUN: mkdir -p %t
3
3
//
4
4
// 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
7
11
//
8
12
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-run %t/Dictionary
9
13
// REQUIRES: executable_test
10
14
11
- // XFAIL: linux
12
-
15
+ #if os(OSX) || os(iOS) || os(tvOS) || os(watchOS)
13
16
import Darwin
17
+ #else
18
+ import Glibc
19
+ #endif
20
+
14
21
import StdlibUnittest
15
22
import StdlibCollectionUnittest
16
23
17
24
25
+ #if _runtime(_ObjC)
18
26
import Foundation
19
27
import StdlibUnittestFoundationExtras
28
+ #endif
20
29
21
30
// Check that the generic parameters are called 'Key' and 'Value'.
22
31
protocol TestProtocol1 { }
@@ -1142,6 +1151,7 @@ DictionaryTestSuite.test("init(dictionaryLiteral:)") {
1142
1151
}
1143
1152
}
1144
1153
1154
+ #if _runtime(_ObjC)
1145
1155
//===---
1146
1156
// NSDictionary -> Dictionary bridging tests.
1147
1157
//===---
@@ -3405,6 +3415,7 @@ DictionaryTestSuite.test("DictionaryBridgeFromObjectiveCConditional") {
3405
3415
assert ( false )
3406
3416
}
3407
3417
}
3418
+ #endif // _runtime(_ObjC)
3408
3419
3409
3420
//===---
3410
3421
// Tests for APIs implemented strictly based on public interface. We only need
@@ -3421,6 +3432,18 @@ func getDerivedAPIsDictionary() -> Dictionary<Int, Int> {
3421
3432
3422
3433
var DictionaryDerivedAPIs = TestSuite ( " DictionaryDerivedAPIs " )
3423
3434
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)
3424
3447
@objc
3425
3448
class MockDictionaryWithCustomCount : NSDictionary {
3426
3449
init ( count: Int ) {
@@ -3473,17 +3496,6 @@ func getMockDictionaryWithCustomCount(count: Int)
3473
3496
return MockDictionaryWithCustomCount ( count: count) as Dictionary
3474
3497
}
3475
3498
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
-
3487
3499
func callGenericIsEmpty< C : Collection > ( _ collection: C ) -> Bool {
3488
3500
return collection. isEmpty
3489
3501
}
@@ -3515,6 +3527,7 @@ DictionaryDerivedAPIs.test("isEmpty/ImplementationIsCustomized") {
3515
3527
expectEqual ( 1 , MockDictionaryWithCustomCount . timesCountWasCalled)
3516
3528
}
3517
3529
}
3530
+ #endif // _runtime(_ObjC)
3518
3531
3519
3532
DictionaryDerivedAPIs . test ( " keys " ) {
3520
3533
do {
@@ -3547,6 +3560,7 @@ DictionaryDerivedAPIs.test("values") {
3547
3560
}
3548
3561
}
3549
3562
3563
+ #if _runtime(_ObjC)
3550
3564
var ObjCThunks = TestSuite ( " ObjCThunks " )
3551
3565
3552
3566
class ObjCThunksHelper : NSObject {
@@ -3690,6 +3704,7 @@ ObjCThunks.test("Dictionary/Return") {
3690
3704
expectEqual ( 0 , TestBridgedValueTy . bridgeOperations)
3691
3705
}
3692
3706
}
3707
+ #endif // _runtime(_ObjC)
3693
3708
3694
3709
//===---
3695
3710
// Check that iterators traverse a snapshot of the collection.
@@ -3817,6 +3832,7 @@ DictionaryTestSuite.test("misc") {
3817
3832
}
3818
3833
}
3819
3834
3835
+ #if _runtime(_ObjC)
3820
3836
DictionaryTestSuite . test ( " dropsBridgedCache " ) {
3821
3837
// rdar://problem/18544533
3822
3838
// Previously this code would segfault due to a double free in the Dictionary
@@ -3856,6 +3872,7 @@ DictionaryTestSuite.test("getObjects:andKeys:") {
3856
3872
expectEqual ( [ 2 , 1 ] as [ NSNumber ] , Array ( keys) )
3857
3873
expectEqual ( [ " two " , " one " ] as [ NSString ] , Array ( values) )
3858
3874
}
3875
+ #endif
3859
3876
3860
3877
DictionaryTestSuite . test ( " popFirst " ) {
3861
3878
// Empty
@@ -3904,12 +3921,16 @@ DictionaryTestSuite.test("removeAt") {
3904
3921
3905
3922
DictionaryTestSuite . setUp {
3906
3923
resetLeaksOfDictionaryKeysValues ( )
3924
+ #if _runtime(_ObjC)
3907
3925
resetLeaksOfObjCDictionaryKeysValues ( )
3926
+ #endif
3908
3927
}
3909
3928
3910
3929
DictionaryTestSuite . tearDown {
3911
3930
expectNoLeaksOfDictionaryKeysValues ( )
3931
+ #if _runtime(_ObjC)
3912
3932
expectNoLeaksOfObjCDictionaryKeysValues ( )
3933
+ #endif
3913
3934
}
3914
3935
3915
3936
runAllTests ( )
0 commit comments