// RUN: %target-run-simple-swift // REQUIRES: executable_test import StdlibUnittest var tuples = TestSuite("VariadicGenericTuples") // Metadata instantiation for tuples containing pack expansions func makeTuple(_: repeat (each T).Type) -> Any.Type { return (repeat Array).self } tuples.test("makeTuple") { expectEqual("()", _typeName(makeTuple())) // Note that we unwrap the one-element tuple! expectEqual("Swift.Array", _typeName(makeTuple(Int.self))) expectEqual("(Swift.Array, Swift.Array)", _typeName(makeTuple(Int.self, String.self))) expectEqual("(Swift.Array, Swift.Array, Swift.Array)", _typeName(makeTuple(Int.self, String.self, Float.self))) } func makeTuple2(_: repeat (each T).Type) -> Any.Type { return (Int, repeat Array).self } tuples.test("makeTuple2") { // Note that we unwrap the one-element tuple! expectEqual("Swift.Int", _typeName(makeTuple2())) expectEqual("(Swift.Int, Swift.Array)", _typeName(makeTuple2(Bool.self))) expectEqual("(Swift.Int, Swift.Array, Swift.Array)", _typeName(makeTuple2(Bool.self, Character.self))) expectEqual("(Swift.Int, Swift.Array, Swift.Array, Swift.Array)", _typeName(makeTuple2(Bool.self, Character.self, Double.self))) } func makeTuple3(t: repeat (each T).Type, u: repeat (each U).Type) -> Any.Type { return (repeat each T, repeat each U).self } tuples.test("makeTuple3") { expectEqual("()", _typeName(makeTuple3())) // Note that we unwrap the one-element tuple! expectEqual("Swift.Int", _typeName(makeTuple3(t: Int.self))) expectEqual("Swift.Int", _typeName(makeTuple3(u: Int.self))) expectEqual("(Swift.Int, Swift.Float)", _typeName(makeTuple3(t: Int.self, u: Float.self))) } func makeTuple( _ element: repeat each Element ) -> (repeat each Element) { return (repeat each element) } func expandTupleElements(_ value: repeat each T) { let values = makeTuple(repeat each value) _ = (repeat expectEqual(each value, each values)) } tuples.test("expandTuple") { expandTupleElements(1, "hello", true) } runAllTests()