Skip to content

Commit 4845059

Browse files
committed
Test reflection for classes containing multiple types
1 parent 41177fa commit 4845059

File tree

1 file changed

+147
-0
lines changed

1 file changed

+147
-0
lines changed
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
// RUN: rm -rf %t && mkdir -p %t
2+
// RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_multiple_types
3+
// RUN: %target-run %target-swift-reflection-test %t/reflect_multiple_types 2>&1 | FileCheck %s --check-prefix=CHECK-%target-ptrsize
4+
// REQUIRES: objc_interop
5+
// REQUIRES: executable_test
6+
7+
import SwiftReflectionTest
8+
import Foundation
9+
10+
class TestClass {
11+
var t00: Array<Int>
12+
var t01: Bool
13+
var t02: Character
14+
var t03: Dictionary<Int, Int>
15+
var t04: Double
16+
var t05: Float
17+
var t06: Int
18+
var t07: Int16
19+
var t08: Int32
20+
var t09: Int64
21+
var t10: Int8
22+
var t11: NSArray
23+
var t12: NSNumber
24+
var t13: NSSet
25+
var t14: NSString
26+
var t15: Set<Int>
27+
var t16: String
28+
var t17: UInt
29+
var t18: UInt16
30+
var t19: UInt32
31+
var t20: UInt64
32+
var t21: UInt8
33+
init(
34+
t00: Array<Int>,
35+
t01: Bool,
36+
t02: Character,
37+
t03: Dictionary<Int, Int>,
38+
t04: Double,
39+
t05: Float,
40+
t06: Int,
41+
t07: Int16,
42+
t08: Int32,
43+
t09: Int64,
44+
t10: Int8,
45+
t11: NSArray,
46+
t12: NSNumber,
47+
t13: NSSet,
48+
t14: NSString,
49+
t15: Set<Int>,
50+
t16: String,
51+
t17: UInt,
52+
t18: UInt16,
53+
t19: UInt32,
54+
t20: UInt64,
55+
t21: UInt8
56+
) {
57+
self.t00 = t00
58+
self.t01 = t01
59+
self.t02 = t02
60+
self.t03 = t03
61+
self.t04 = t04
62+
self.t05 = t05
63+
self.t06 = t06
64+
self.t07 = t07
65+
self.t08 = t08
66+
self.t09 = t09
67+
self.t10 = t10
68+
self.t11 = t11
69+
self.t12 = t12
70+
self.t13 = t13
71+
self.t14 = t14
72+
self.t15 = t15
73+
self.t16 = t16
74+
self.t17 = t17
75+
self.t18 = t18
76+
self.t19 = t19
77+
self.t20 = t20
78+
self.t21 = t21
79+
}
80+
}
81+
82+
var obj = TestClass(
83+
t00: [1, 2, 3],
84+
t01: true,
85+
t02: "A",
86+
t03: [1: 3, 2: 2, 3: 1],
87+
t04: 123.45,
88+
t05: 123.45,
89+
t06: 123,
90+
t07: 123,
91+
t08: 123,
92+
t09: 123,
93+
t10: 123,
94+
t11: [1, 2, 3],
95+
t12: 123,
96+
t13: [1, 2, 3, 3, 2, 1],
97+
t14: "Hello, NSString!",
98+
t15: [1, 2, 3, 3, 2, 1],
99+
t16: "Hello, Reflection!",
100+
t17: 123,
101+
t18: 123,
102+
t19: 123,
103+
t20: 123,
104+
t21: 123
105+
)
106+
107+
reflect(object: obj)
108+
109+
// CHECK-64: Reflecting an object.
110+
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
111+
// CHECK-64: Type reference:
112+
// CHECK-64: (class reflect_multiple_types.TestClass)
113+
114+
// CHECK-64: Type info:
115+
// CHECK-64: <null type info>
116+
117+
// CHECK-32: Reflecting an object.
118+
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
119+
// CHECK-32: Type reference:
120+
// CHECK-32: (class reflect_multiple_types.TestClass)
121+
122+
// CHECK-32: Type info:
123+
// CHECK-32: <null type info>
124+
125+
reflect(any: obj)
126+
127+
// CHECK-64: Reflecting an existential.
128+
// CHECK-64: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
129+
// CHECK-64: Type reference:
130+
// CHECK-64: (class reflect_multiple_types.TestClass)
131+
132+
// CHECK-64: Type info:
133+
// CHECK-64: (reference kind=strong refcounting=native)
134+
135+
// CHECK-32: Reflecting an existential.
136+
// CHECK-32: Instance pointer in child address space: 0x{{[0-9a-fA-F]+}}
137+
// CHECK-32: Type reference:
138+
// CHECK-32: (class reflect_multiple_types.TestClass)
139+
140+
// CHECK-32: Type info:
141+
// CHECK-32: (reference kind=strong refcounting=native)
142+
143+
doneReflecting()
144+
145+
// CHECK-64: Done.
146+
147+
// CHECK-32: Done.

0 commit comments

Comments
 (0)