Skip to content

Commit bd0613f

Browse files
committed
Test that we handle metadata cycles in a bunch of different situations.
rdar://18157434
1 parent 6c31586 commit bd0613f

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// RUN: %target-run-simple-swift
2+
// REQUIRES: executable_test
3+
4+
import StdlibUnittest
5+
6+
var MetadataCycleTests = TestSuite("Metadata cycle tests")
7+
8+
// rdar://18448285
9+
class test0_GenericClass<T> {
10+
func foo() {}
11+
}
12+
class test0_GenericSubclass<T> : test0_GenericClass<test0_GenericSubclass> {}
13+
MetadataCycleTests.test("rdar://18448285") {
14+
test0_GenericSubclass<Int>().foo()
15+
}
16+
17+
// rdar://18685206
18+
final class test1_Box<T> {
19+
init(_ value: T) {
20+
self.value = value
21+
}
22+
let value: T
23+
}
24+
enum test1_List<T> {
25+
case Nil
26+
case Cons(T, test1_Box<test1_List<T>>)
27+
var head: T? {
28+
switch self {
29+
case .Nil:
30+
return nil
31+
case .Cons(let h, _):
32+
return h
33+
}
34+
}
35+
}
36+
MetadataCycleTests.test("rdar://18685206") {
37+
let x: test1_List<Int> = .Nil
38+
_ = x.head
39+
}
40+
41+
// rdar://18847269
42+
struct test2_Thunk<T> {}
43+
enum test2_List<T> {
44+
case Nil
45+
case Cons(T, test2_Thunk<test2_List>)
46+
}
47+
MetadataCycleTests.test("rdar://18847269") {
48+
let il0: test2_List<Int> = .Nil
49+
_ = il0
50+
}
51+
52+
// rdar://18903483
53+
final class test3_Box<T> {
54+
private let _value : () -> T
55+
init(_ value : T) {
56+
self._value = { value }
57+
}
58+
}
59+
enum test3_List<A> {
60+
case Nil
61+
case Cons(A, test3_Box<test3_List<A>>)
62+
}
63+
MetadataCycleTests.test("rdar://18903483") {
64+
let x : test3_List<Int> = .Nil
65+
_ = x
66+
67+
// rdar://19371082
68+
_ = test3_List.Cons(7, test3_Box(test3_List.Nil))
69+
}
70+
71+
// rdar://19320857
72+
struct test4_RoseTree<T> {
73+
let value: T
74+
let branches: [test4_RoseTree]
75+
}
76+
MetadataCycleTests.test("rdar://19320857") {
77+
_ = test4_RoseTree(value: 1, branches: [])
78+
}
79+
80+
runAllTests()

0 commit comments

Comments
 (0)