|
1 | 1 | // RUN: rm -rf %t && mkdir -p %t/before && mkdir -p %t/after |
2 | | -// RUN: %target-build-swift -emit-module -emit-library -module-name superclass_properties -emit-module-path %t/superclass_properties.swiftmodule -Xfrontend -enable-resilience -D BEFORE %S/Inputs/superclass_properties.swift -o %t/before/superclass_properties.o |
3 | | -// RUN: %target-build-swift -c %s -I %t -Xfrontend -enable-resilience -o %t/main.o |
4 | | -// RUN: %target-build-swift %t/before/superclass_properties.o %t/main.o -o %t/before/main |
5 | | -// RUN: %t/before/main | FileCheck --check-prefix=BEFORE %s |
6 | | -// RUN: %target-build-swift -emit-module -emit-library -module-name superclass_properties -emit-module-path %t/superclass_properties.swiftmodule -Xfrontend -enable-resilience -D AFTER %S/Inputs/superclass_properties.swift -o %t/after/superclass_properties.o |
7 | | -// RUN: %target-build-swift %t/after/superclass_properties.o %t/main.o -o %t/after/main -v |
8 | | -// RUN: %t/after/main | FileCheck --check-prefix=AFTER %s |
9 | 2 |
|
| 3 | +// RUN: %target-build-swift -emit-library -Xfrontend -enable-resilience -D BEFORE -c %S/Inputs/superclass_properties.swift -o %t/before/superclass_properties.o |
| 4 | +// RUN: %target-build-swift -emit-module -Xfrontend -enable-resilience -D BEFORE -c %S/Inputs/superclass_properties.swift -o %t/before/superclass_properties.o |
| 5 | + |
| 6 | +// RUN: %target-build-swift -emit-library -Xfrontend -enable-resilience -D AFTER -c %S/Inputs/superclass_properties.swift -o %t/after/superclass_properties.o |
| 7 | +// RUN: %target-build-swift -emit-module -Xfrontend -enable-resilience -D AFTER -c %S/Inputs/superclass_properties.swift -o %t/after/superclass_properties.o |
| 8 | + |
| 9 | +// RUN: %target-build-swift -D BEFORE -c %s -I %t/before -o %t/before/main.o |
| 10 | +// RUN: %target-build-swift -D AFTER -c %s -I %t/after -o %t/after/main.o |
| 11 | + |
| 12 | +// RUN: %target-build-swift %t/before/superclass_properties.o %t/before/main.o -o %t/before_before |
| 13 | +// RUN: %target-build-swift %t/before/superclass_properties.o %t/after/main.o -o %t/before_after |
| 14 | +// RUN: %target-build-swift %t/after/superclass_properties.o %t/before/main.o -o %t/after_before |
| 15 | +// RUN: %target-build-swift %t/after/superclass_properties.o %t/after/main.o -o %t/after_after |
| 16 | + |
| 17 | +// RUN: %target-run %t/before_before |
| 18 | +// RUN: %target-run %t/before_after |
| 19 | +// RUN: %target-run %t/after_before |
| 20 | +// RUN: %target-run %t/after_after |
| 21 | + |
| 22 | +import StdlibUnittest |
10 | 23 | import superclass_properties |
11 | 24 |
|
12 | | -do { |
13 | | - class Leaf : AddInterposingProperty { |
14 | | - override var property: String { |
15 | | - return super.property |
| 25 | +var SuperclassPropertiesTest = TestSuite("SuperclassProperties") |
| 26 | + |
| 27 | +SuperclassPropertiesTest.test("AddInterposingProperty") { |
| 28 | + do { |
| 29 | + class Leaf : AddInterposingProperty { |
| 30 | + override var property: String { |
| 31 | + return super.property |
| 32 | + } |
| 33 | + override class var classProperty: String { |
| 34 | + return super.classProperty |
| 35 | + } |
16 | 36 | } |
17 | | - override class var classProperty: String { |
18 | | - return super.classProperty |
| 37 | + if getVersion() == 0 { |
| 38 | + expectEqual(Leaf().property, "Base.property") |
| 39 | + expectEqual(Leaf.classProperty, "Base.classProperty") |
| 40 | + } else { |
| 41 | + expectEqual(Leaf().property, "AddInterposingProperty.property") |
| 42 | + expectEqual(Leaf.classProperty, "AddInterposingProperty.classProperty") |
19 | 43 | } |
20 | 44 | } |
21 | | - let leaf = Leaf() |
22 | | - print(leaf.property) |
23 | | - print(Leaf.classProperty) |
24 | | - // BEFORE: Base.property |
25 | | - // BEFORE: Base.classProperty |
26 | | - // AFTER: AddInterposingProperty.property |
27 | | - // AFTER: AddInterposingProperty.classProperty |
28 | 45 | } |
29 | 46 |
|
30 | | -do { |
31 | | - class Leaf : RemoveInterposingProperty { |
32 | | - override var property: String { |
33 | | - return super.property |
| 47 | +SuperclassPropertiesTest.test("RemoveInterposingProperty") { |
| 48 | + do { |
| 49 | + class Leaf : RemoveInterposingProperty { |
| 50 | + override var property: String { |
| 51 | + return super.property |
| 52 | + } |
| 53 | + override class var classProperty: String { |
| 54 | + return super.classProperty |
| 55 | + } |
34 | 56 | } |
35 | | - override class var classProperty: String { |
36 | | - return super.classProperty |
| 57 | + if getVersion() == 0 { |
| 58 | + expectEqual(Leaf().property, "RemoveInterposingProperty.property") |
| 59 | + expectEqual(Leaf.classProperty, "RemoveInterposingProperty.classProperty") |
| 60 | + } else { |
| 61 | + expectEqual(Leaf().property, "Base.property") |
| 62 | + expectEqual(Leaf.classProperty, "Base.classProperty") |
37 | 63 | } |
38 | 64 | } |
39 | | - print(Leaf().property) |
40 | | - print(Leaf.classProperty) |
41 | | - // BEFORE: RemoveInterposingProperty.property |
42 | | - // BEFORE: RemoveInterposingProperty.classProperty |
43 | | - // AFTER: Base.property |
44 | | - // AFTER: Base.classProperty |
45 | 65 | } |
46 | 66 |
|
47 | | -do { |
48 | | - class Leaf : InsertSuperclass { |
49 | | - override var property: String { |
50 | | - return super.property |
| 67 | +SuperclassPropertiesTest.test("InsertSuperclass") { |
| 68 | + do { |
| 69 | + class Leaf : InsertSuperclass { |
| 70 | + override var property: String { |
| 71 | + return super.property |
| 72 | + } |
| 73 | + override class var classProperty: String { |
| 74 | + return super.classProperty |
| 75 | + } |
51 | 76 | } |
52 | | - override class var classProperty: String { |
53 | | - return super.classProperty |
| 77 | + if getVersion() == 0 { |
| 78 | + expectEqual(Leaf().property, "Base.property") |
| 79 | + expectEqual(Leaf.classProperty, "Base.classProperty") |
| 80 | + } else { |
| 81 | + expectEqual(Leaf().property, "InBetween.property") |
| 82 | + expectEqual(Leaf.classProperty, "InBetween.classProperty") |
54 | 83 | } |
55 | 84 | } |
56 | | - print(Leaf().property) |
57 | | - print(Leaf.classProperty) |
58 | | - // BEFORE: Base.property |
59 | | - // BEFORE: Base.classProperty |
60 | | - // AFTER: InBetween.property |
61 | | - // AFTER: InBetween.classProperty |
62 | 85 | } |
63 | 86 |
|
64 | | -do { |
65 | | - class Leaf : ChangeRoot { |
66 | | - override var property: String { |
67 | | - return super.property |
| 87 | +SuperclassPropertiesTest.test("ChangeRoot") { |
| 88 | + do { |
| 89 | + class Leaf : ChangeRoot { |
| 90 | + override var property: String { |
| 91 | + return super.property |
| 92 | + } |
| 93 | + override class var classProperty: String { |
| 94 | + return super.classProperty |
| 95 | + } |
68 | 96 | } |
69 | | - override class var classProperty: String { |
70 | | - return super.classProperty |
| 97 | + if getVersion() == 0 { |
| 98 | + expectEqual(Leaf().property, "Base.property") |
| 99 | + expectEqual(Leaf.classProperty, "Base.classProperty") |
| 100 | + } else { |
| 101 | + expectEqual(Leaf().property, "OtherBase.property") |
| 102 | + expectEqual(Leaf.classProperty, "OtherBase.classProperty") |
71 | 103 | } |
72 | 104 | } |
73 | | - print(Leaf().property) |
74 | | - print(Leaf.classProperty) |
75 | | - // BEFORE: Base.property |
76 | | - // BEFORE: Base.classProperty |
77 | | - // AFTER: OtherBase.property |
78 | | - // AFTER: OtherBase.classProperty |
79 | 105 | } |
| 106 | + |
| 107 | +runAllTests() |
0 commit comments