1+ // RUN: %target-run-simple-swift(-enable-experimental-feature VariadicGenerics -Xfrontend -disable-concrete-type-metadata-mangled-name-accessors)
2+
3+ // FIXME: Get it to build without -disable-concrete-type-metadata-mangled-name-accessors and test both
4+
5+ // REQUIRES: executable_test
6+
7+ // Because of -enable-experimental-feature VariadicGenerics
8+ // REQUIRES: asserts
9+
10+ import StdlibUnittest
11+
12+ var types = TestSuite ( " VariadicGenericTypes " )
13+
14+ public struct Outer < each U >
15+ where each U : Equatable {
16+
17+ public struct Inner < each V >
18+ where each V : Equatable {
19+ }
20+
21+ public struct InnerSameShape < each V >
22+ where each V : Equatable ,
23+ ( repeat ( each U , each V ) ) : Any {
24+ }
25+ }
26+
27+ types. test ( " Outer " ) {
28+ expectEqual ( " main.Outer<Pack{}> " , _typeName ( Outer< > . self) )
29+ expectEqual ( " main.Outer<Pack{Swift.Int}> " , _typeName ( Outer< Int> . self ) )
30+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String}> " , _typeName ( Outer< Int, String> . self ) )
31+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String, Swift.Float}> " , _typeName ( Outer< Int, String, Float> . self ) )
32+ }
33+
34+ types. test ( " Outer.Inner " ) {
35+ expectEqual ( " main.Outer<Pack{}>.Inner<Pack{}> " , _typeName ( Outer< > . Inner< > . self) )
36+ expectEqual ( " main.Outer<Pack{Swift.Int}>.Inner<Pack{}> " , _typeName ( Outer < Int > . Inner< > . self) )
37+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String}>.Inner<Pack{}> " , _typeName ( Outer < Int , String > . Inner< > . self) )
38+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String, Swift.Float}>.Inner<Pack{}> " , _typeName ( Outer < Int , String , Float > . Inner< > . self) )
39+
40+ expectEqual ( " main.Outer<Pack{}>.Inner<Pack{Swift.Bool}> " , _typeName ( Outer< > . Inner< Bool> . self ) )
41+ expectEqual ( " main.Outer<Pack{Swift.Int}>.Inner<Pack{Swift.Bool}> " , _typeName ( Outer < Int > . Inner< Bool> . self ) )
42+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String}>.Inner<Pack{Swift.Bool}> " , _typeName ( Outer < Int , String > . Inner< Bool> . self ) )
43+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String, Swift.Float}>.Inner<Pack{Swift.Bool}> " , _typeName ( Outer < Int , String , Float > . Inner< Bool> . self ) )
44+
45+ expectEqual ( " main.Outer<Pack{}>.Inner<Pack{Swift.Bool, Swift.Double}> " , _typeName ( Outer< > . Inner< Bool, Double> . self ) )
46+ expectEqual ( " main.Outer<Pack{Swift.Int}>.Inner<Pack{Swift.Bool, Swift.Double}> " , _typeName ( Outer < Int > . Inner< Bool, Double> . self ) )
47+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String}>.Inner<Pack{Swift.Bool, Swift.Double}> " , _typeName ( Outer< Int, String> . Inner< Bool, Double> . self ) )
48+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String, Swift.Float}>.Inner<Pack{Swift.Bool, Swift.Double}> " , _typeName ( Outer< Int, String, Float> . Inner< Bool, Double> . self ) )
49+
50+ expectEqual ( " main.Outer<Pack{}>.Inner<Pack{Swift.Bool, Swift.Double, Swift.Character}> " , _typeName ( Outer< > . Inner< Bool, Double, Character> . self ) )
51+ expectEqual ( " main.Outer<Pack{Swift.Int}>.Inner<Pack{Swift.Bool, Swift.Double, Swift.Character}> " , _typeName ( Outer < Int > . Inner< Bool, Double, Character> . self ) )
52+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String}>.Inner<Pack{Swift.Bool, Swift.Double, Swift.Character}> " , _typeName ( Outer< Int, String> . Inner< Bool, Double, Character> . self ) )
53+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String, Swift.Float}>.Inner<Pack{Swift.Bool, Swift.Double, Swift.Character}> " , _typeName ( Outer< Int, String, Float> . Inner< Bool, Double, Character> . self ) )
54+ }
55+
56+ types. test ( " Outer.InnerSameShape " ) {
57+ expectEqual ( " main.Outer<Pack{}>.InnerSameShape<Pack{}> " , _typeName ( Outer< > . InnerSameShape< > . self) )
58+ expectEqual ( " main.Outer<Pack{Swift.Int}>.InnerSameShape<Pack{Swift.Bool}> " , _typeName ( Outer < Int > . InnerSameShape< Bool> . self ) )
59+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String}>.InnerSameShape<Pack{Swift.Bool, Swift.Double}> " , _typeName ( Outer< Int, String> . InnerSameShape< Bool, Double> . self ) )
60+ expectEqual ( " main.Outer<Pack{Swift.Int, Swift.String, Swift.Float}>.InnerSameShape<Pack{Swift.Bool, Swift.Double, Swift.Character}> " , _typeName ( Outer< Int, String, Float> . InnerSameShape< Bool, Double, Character> . self ) )
61+ }
62+
63+ runAllTests ( )
0 commit comments