|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// |
| 3 | +// RUN: %target-build-swift-dylib(%t/%target-library-name(variadic_generic_opaque_type_other)) %S/Inputs/variadic_generic_opaque_type_other.swift -emit-module -emit-module-path %t/variadic_generic_opaque_type_other.swiftmodule -module-name variadic_generic_opaque_type_other -Xfrontend -disable-availability-checking -enable-library-evolution |
| 4 | +// RUN: %target-codesign %t/%target-library-name(variadic_generic_opaque_type_other) |
| 5 | +// |
| 6 | +// RUN: %target-build-swift %s -I %t -o %t/main.out -L %t %target-rpath(%t) -lvariadic_generic_opaque_type_other |
| 7 | +// RUN: %target-codesign %t/main.out |
| 8 | +// |
| 9 | +// RUN: %target-run %t/main.out %t/%target-library-name(variadic_generic_opaque_type_other) |
| 10 | + |
| 11 | +// REQUIRES: executable_test |
| 12 | + |
| 13 | +import variadic_generic_opaque_type_other |
| 14 | +import StdlibUnittest |
| 15 | + |
| 16 | +var opaque = TestSuite("VariadicGenericOpaqueTypes") |
| 17 | + |
| 18 | +func getType<T>(_: T) -> Any.Type { |
| 19 | + return T.self |
| 20 | +} |
| 21 | + |
| 22 | +opaque.test("Opaque1") { |
| 23 | + expectEqual((Int, String).self, getType(f1(1, "hi"))) |
| 24 | + expectEqual(G2<(Bool, String)>.self, getType(f2(false, "hi"))) |
| 25 | + expectEqual(G3<Bool, Double>.self, getType(f3(false, 3.0))) |
| 26 | +} |
| 27 | + |
| 28 | +func g1<each T: P>(_ t: repeat each T) -> Any.Type { |
| 29 | + return getType(f1(repeat each t)) |
| 30 | +} |
| 31 | +func g2<each T: P>(_ t: repeat each T) -> Any.Type { |
| 32 | + return getType(f2(repeat each t)) |
| 33 | +} |
| 34 | +func g3<each T: P>(_ t: repeat each T) -> Any.Type { |
| 35 | + return getType(f3(repeat each t)) |
| 36 | +} |
| 37 | + |
| 38 | +opaque.test("Opaque2") { |
| 39 | + expectEqual((Int, String).self, g1(1, "hi")) |
| 40 | + expectEqual(G2<(Bool, String)>.self, g2(false, "hi")) |
| 41 | + expectEqual(G3<Bool, Double>.self, g3(false, 3.0)) |
| 42 | +} |
| 43 | + |
| 44 | +runAllTests() |
0 commit comments