1
1
// RUN: %target-run-simple-swift(-enable-experimental-feature VariadicGenerics -Xfrontend -disable-concrete-type-metadata-mangled-name-accessors)
2
2
// RUN: %target-run-simple-swift(-enable-experimental-feature VariadicGenerics)
3
3
4
+ // FIXME: Fix the optimizer
5
+ // REQUIRES: swift_test_mode_optimize_none
6
+
4
7
// REQUIRES: executable_test
5
8
6
9
// Because of -enable-experimental-feature VariadicGenerics
@@ -13,6 +16,10 @@ import StdlibUnittest
13
16
14
17
var types = TestSuite ( " VariadicGenericTypes " )
15
18
19
+ //
20
+ // Metadata instantiation tests
21
+ //
22
+
16
23
public struct Outer < each U > {
17
24
public struct Inner < each V > { }
18
25
@@ -66,4 +73,46 @@ types.test("ConformanceReq") {
66
73
67
74
// FIXME: Test superclass, layout and same-type pack requirements once more stuff is plumbed through
68
75
76
+ //
77
+ // Stored property layout tests
78
+ //
79
+
80
+ public struct FancyTuple < each T > {
81
+ private var x : ( repeat each T )
82
+ }
83
+
84
+ public func returnSize< T> ( _: T . Type ) -> Int {
85
+ return MemoryLayout< T> . size
86
+ }
87
+
88
+ types. test ( " FancyTuple " ) {
89
+ expectEqual ( returnSize ( FancyTuple< > . self) ,
90
+ returnSize ( Void . self) )
91
+ expectEqual ( returnSize ( FancyTuple< Int8> . self ) ,
92
+ returnSize ( ( Int8) . self) )
93
+ expectEqual ( returnSize ( FancyTuple< Int8, Int16> . self ) ,
94
+ returnSize ( ( Int8, Int16) . self) )
95
+ expectEqual ( returnSize ( FancyTuple< Int8, Int16, Int32> . self ) ,
96
+ returnSize ( ( Int8, Int16, Int32) . self) )
97
+ expectEqual ( returnSize ( FancyTuple< Int8, Int16, Int32, Int64> . self ) ,
98
+ returnSize ( ( Int8, Int16, Int32, Int64) . self) )
99
+ }
100
+
101
+ public struct SequenceElementTuple < each T : Sequence > {
102
+ private var x : ( repeat ( each T ) . Element)
103
+ }
104
+
105
+ types. test ( " SequenceElementTuple " ) {
106
+ expectEqual ( returnSize ( SequenceElementTuple< > . self) ,
107
+ returnSize ( Void . self) )
108
+ expectEqual ( returnSize ( SequenceElementTuple< Array< Int8>>. self ) ,
109
+ returnSize ( ( Int8) . self) )
110
+ expectEqual ( returnSize ( SequenceElementTuple < Array < Int8 > , Array < Int16 > > . self) ,
111
+ returnSize ( ( Int8, Int16) . self) )
112
+ expectEqual ( returnSize ( SequenceElementTuple < Array < Int8 > , Array < Int16 > , Array < Int32 > > . self) ,
113
+ returnSize ( ( Int8, Int16, Int32) . self) )
114
+ expectEqual ( returnSize ( SequenceElementTuple < Array < Int8 > , Array < Int16 > , Array < Int32 > , Array < Int64 > > . self) ,
115
+ returnSize ( ( Int8, Int16, Int32, Int64) . self) )
116
+ }
117
+
69
118
runAllTests ( )
0 commit comments