Skip to content

Commit b09b9b9

Browse files
committed
Expand testing of label validation in casting
1 parent b5b5ace commit b09b9b9

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

test/Interpreter/tuple_casts.swift

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
// RUN: %target-run-simple-swift
2-
// RUN: %target-build-swift -O %s -o %t/a.out.optimized
3-
// RUN: %target-codesign %t/a.out.optimized
4-
// RUN: %target-run %t/a.out.optimized
2+
//
3+
// RUN: %target-build-swift -swift-version 5 -O %s -o %t/a.swift5.O.out
4+
// RUN: %target-codesign %t/a.swift5.O.out
5+
// RUN: %target-run %t/a.swift5.O.out
6+
//
7+
// RUN: %target-build-swift -swift-version 5 -Onone %s -o %t/a.swift5.Onone.out
8+
// RUN: %target-codesign %t/a.swift5.Onone.out
9+
// RUN: %target-run %t/a.swift5.Onone.out
10+
//
511
// REQUIRES: executable_test
612

713
import StdlibUnittest
@@ -31,15 +37,31 @@ tupleCastTests.test("Adding/removing labels") {
3137
String(describing: anyToIntPoint((3, 4))))
3238
expectEqual("(x: 5, y: 6)",
3339
String(describing: anyToIntPoint((x: 5, 6))))
40+
expectEqual("(x: 5, y: 6)",
41+
String(describing: anyToIntPoint((5, y: 6))))
3442

3543
expectEqual("(1, 2)", String(describing: anyToInt2((1, 2))))
3644
expectEqual("(3, 4)", String(describing: anyToInt2((x: 3, y: 4))))
3745
expectEqual("(5, 6)", String(describing: anyToInt2((x: 5, 6))))
46+
expectEqual("(7, 8)", String(describing: anyToInt2((7, y: 8))))
3847

3948
expectEqual("(first: 1, 2, third: 3)",
4049
String(describing: anyToPartlyLabeled((1, 2, 3))))
4150
}
4251

52+
tupleCastTests.test("Label checks on casting") {
53+
expectTrue((x: 1, y: 2) is (Int, Int))
54+
expectTrue((x: 1, y: 2) is (x: Int, Int))
55+
expectTrue((x: 1, y: 2) is (Int, y: Int))
56+
expectTrue((x: 1, y: 2) is (x: Int, y: Int))
57+
58+
expectFalse((x: 1, y: 2) is (x: Int, z: Int))
59+
expectFalse((x: 1, y: 2) is (a: Int, y: Int))
60+
expectFalse((x: 1, y: 2) is (a: Int, z: Int))
61+
expectFalse((x: 1, y: 2) is (Int, z: Int))
62+
expectFalse((x: 1, y: 2) is (a: Int, Int))
63+
}
64+
4365
tupleCastTests.test("Incorrect labels conditional cast") {
4466
expectNil(anyToIntPointOpt((x: 1, z: 2)))
4567
expectEqual("Optional((x: 1, y: 2))",

0 commit comments

Comments
 (0)