Skip to content

Commit de73859

Browse files
slavapestovrjmccall
authored andcommitted
Add execution tests for dynamic layout of variadic generic types
1 parent 7d779a9 commit de73859

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/Interpreter/variadic_generic_types.swift

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// RUN: %target-run-simple-swift(-enable-experimental-feature VariadicGenerics -Xfrontend -disable-concrete-type-metadata-mangled-name-accessors)
22
// RUN: %target-run-simple-swift(-enable-experimental-feature VariadicGenerics)
33

4+
// FIXME: Fix the optimizer
5+
// REQUIRES: swift_test_mode_optimize_none
6+
47
// REQUIRES: executable_test
58

69
// Because of -enable-experimental-feature VariadicGenerics
@@ -13,6 +16,10 @@ import StdlibUnittest
1316

1417
var types = TestSuite("VariadicGenericTypes")
1518

19+
//
20+
// Metadata instantiation tests
21+
//
22+
1623
public struct Outer<each U> {
1724
public struct Inner<each V> {}
1825

@@ -66,4 +73,46 @@ types.test("ConformanceReq") {
6673

6774
// FIXME: Test superclass, layout and same-type pack requirements once more stuff is plumbed through
6875

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+
69118
runAllTests()

0 commit comments

Comments
 (0)