Skip to content

Commit 6593817

Browse files
committed
[test] Update BridgeStorage tests
1 parent 80ebdfc commit 6593817

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

test/stdlib/BridgeStorage.swift.gyb renamed to test/stdlib/BridgeStorage.swift

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// distinguish these cases efficiently.
1616
//
1717
//===----------------------------------------------------------------------===//
18-
// RUN: %target-run-simple-swiftgyb
18+
// RUN: %target-run-stdlib-swift
1919
// REQUIRES: executable_test
2020

2121
// REQUIRES: objc_interop
@@ -29,18 +29,17 @@ protocol BridgeStorage {
2929
associatedtype Native : AnyObject
3030
associatedtype ObjC : AnyObject
3131

32-
init(native: Native, bits: Int)
32+
init(native: Native, isFlagged: Bool)
3333
init(native: Native)
3434
init(objC: ObjC)
3535

3636
mutating func isUniquelyReferencedNative() -> Bool
37-
mutating func isUniquelyReferenced_native_noSpareBits() -> Bool
37+
mutating func isUniquelyReferencedUnflaggedNative() -> Bool
3838
var isNative: Bool {get}
3939
var isObjC: Bool {get}
4040
var nativeInstance: Native {get}
41-
var nativeInstance_noSpareBits: Native {get}
41+
var unflaggedNativeInstance: Native {get}
4242
var objCInstance: ObjC {get}
43-
var spareBits: Int {get}
4443
}
4544

4645
extension _BridgeStorage : BridgeStorage {}
@@ -116,42 +115,41 @@ var unTaggedNSString : NSString {
116115
return expectTagged("fûtbōl" as NSString, false)
117116
}
118117

119-
% for Self in ['_BridgeStorage']:
120-
allTests.test("${Self}") {
121-
typealias B = ${Self}<C, NSString>
118+
allTests.test("_BridgeStorage") {
119+
typealias B = _BridgeStorage<C, NSString>
122120

123121
let oy: NSString = "oy"
124122
expectTrue(B(objC: oy).objCInstance == oy)
125123

126-
for i in 0..<2 {
124+
for flag in [false, true] {
127125
do {
128-
var b = B(native: C(), bits: i)
126+
var b = B(native: C(), isFlagged: flag)
129127
expectFalse(b.isObjC)
130128
expectTrue(b.isNative)
129+
expectEqual(!flag, b.isUnflaggedNative)
131130
expectTrue(b.isUniquelyReferencedNative())
132-
if i == 0 {
133-
expectTrue(b.isUniquelyReferenced_native_noSpareBits())
131+
if !flag {
132+
expectTrue(b.isUniquelyReferencedUnflaggedNative())
134133
}
135-
expectEqual(i, b.spareBits)
136134
}
137135

138136
do {
139137
let c = C()
140-
var b = B(native: c, bits: i)
138+
var b = B(native: c, isFlagged: flag)
141139
expectFalse(b.isObjC)
142140
expectTrue(b.isNative)
143141
expectFalse(b.isUniquelyReferencedNative())
144-
expectEqual(i, b.spareBits)
142+
expectEqual(!flag, b.isUnflaggedNative)
145143
expectTrue(b.nativeInstance === c)
146-
if i == 0 {
147-
expectTrue(b.nativeInstance_noSpareBits === c)
148-
expectFalse(b.isUniquelyReferenced_native_noSpareBits())
144+
if !flag {
145+
expectTrue(b.unflaggedNativeInstance === c)
146+
expectFalse(b.isUniquelyReferencedUnflaggedNative())
149147
}
150148
}
151149

152150
}
153151

154-
var b = B(native: C(), bits: 0)
152+
var b = B(native: C(), isFlagged: false)
155153
expectTrue(b.isUniquelyReferencedNative())
156154

157155
// Add a reference and verify that it's still native but no longer unique
@@ -161,23 +159,24 @@ allTests.test("${Self}") {
161159

162160
let n = C()
163161
var bb = B(native: n)
164-
expectEqual(0, bb.spareBits)
165162
expectTrue(bb.nativeInstance === n)
166163
expectTrue(bb.isNative)
164+
expectTrue(bb.isUnflaggedNative)
167165
expectFalse(bb.isObjC)
168166

169167
var d = B(objC: taggedNSString)
170168
expectFalse(d.isUniquelyReferencedNative())
171169
expectFalse(d.isNative)
170+
expectFalse(d.isUnflaggedNative)
172171
expectTrue(d.isObjC)
173172

174173
d = B(objC: unTaggedNSString)
175174
expectFalse(d.isUniquelyReferencedNative())
176175
expectFalse(d.isNative)
176+
expectFalse(d.isUnflaggedNative)
177177
expectTrue(d.isObjC)
178178

179179
}
180-
% end
181180

182181
runAllTests()
183182

0 commit comments

Comments
 (0)