1+ // RUN: %target-run-simple-swift(-enable-experimental-feature VariadicGenerics)
2+
3+ // FIXME: Fix the optimizer
4+ // REQUIRES: swift_test_mode_optimize_none
5+
6+ // REQUIRES: executable_test
7+
8+ // Because of -enable-experimental-feature VariadicGenerics
9+ // REQUIRES: asserts
10+
11+ import StdlibUnittest
12+
13+ var tuples = TestSuite ( " VariadicGenericTuples " )
14+
15+ // Metadata instantiation for tuples containing pack expansions
16+
17+ func makeTuple< each T > ( _: repeat ( each T ) . Type) -> Any . Type {
18+ return ( repeat Array < each T > ) . self
19+ }
20+
21+ tuples. test ( " makeTuple " ) {
22+ expectEqual ( " () " , _typeName ( makeTuple ( ) ) )
23+
24+ // FIXME: This should unwrap the one-element tuple!
25+ expectEqual ( " (Swift.Array<Swift.Int>) " , _typeName ( makeTuple ( Int . self) ) )
26+
27+ expectEqual ( " (Swift.Array<Swift.Int>, Swift.Array<Swift.String>) " , _typeName ( makeTuple ( Int . self, String . self) ) )
28+ expectEqual ( " (Swift.Array<Swift.Int>, Swift.Array<Swift.String>, Swift.Array<Swift.Float>) " , _typeName ( makeTuple ( Int . self, String . self, Float . self) ) )
29+ }
30+
31+ func makeTuple2< each T > ( _: repeat ( each T ) . Type) -> Any . Type {
32+ return ( Int, repeat Array < each T > ) . self
33+ }
34+
35+ tuples. test ( " makeTuple2 " ) {
36+ // FIXME: This should unwrap the one-element tuple!
37+ expectEqual ( " (Swift.Int) " , _typeName ( makeTuple2 ( ) ) )
38+
39+ expectEqual ( " (Swift.Int, Swift.Array<Swift.Bool>) " , _typeName ( makeTuple2 ( Bool . self) ) )
40+ expectEqual ( " (Swift.Int, Swift.Array<Swift.Bool>, Swift.Array<Swift.Character>) " , _typeName ( makeTuple2 ( Bool . self, Character . self) ) )
41+ expectEqual ( " (Swift.Int, Swift.Array<Swift.Bool>, Swift.Array<Swift.Character>, Swift.Array<Swift.Double>) " , _typeName ( makeTuple2 ( Bool . self, Character . self, Double . self) ) )
42+ }
43+
44+ func makeTuple3< each T , each U > ( t: repeat ( each T ) . Type, u: repeat ( each U ) . Type) -> Any . Type {
45+ return ( repeat each T, repeat each U) . self
46+ }
47+
48+ tuples. test ( " makeTuple3 " ) {
49+ expectEqual ( " () " , _typeName ( makeTuple3 ( ) ) )
50+
51+ // FIXME: This should unwrap the one-element tuple!
52+ expectEqual ( " (Swift.Int) " , _typeName ( makeTuple3 ( t: Int . self) ) )
53+
54+ // FIXME: This should unwrap the one-element tuple!
55+ expectEqual ( " (Swift.Int) " , _typeName ( makeTuple3 ( u: Int . self) ) )
56+
57+ expectEqual ( " (Swift.Int, Swift.Float) " , _typeName ( makeTuple3 ( t: Int . self, u: Float . self) ) )
58+ }
59+
60+ runAllTests ( )
0 commit comments