Skip to content

Commit 2ff227b

Browse files
committed
add test
1 parent d1f7555 commit 2ff227b

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

tests/run/i15399.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Expected failure when pass Tuple3 to TupleMirror(2):
2+
- expected Product with 2 elements, got 3
3+
Expected failure when pass Tuple1 to TupleMirror(2):
4+
- expected Product with 2 elements, got 1

tests/run/i15399.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@main def Test =
2+
val tup2Mirror = summon[scala.deriving.Mirror.Of[(Int, Int)]]
3+
try
4+
val tup2a: (Int, Int) = tup2Mirror.fromProduct((1, 2, 3)) // fails silently and creates (1, 2)
5+
println(tup2a) // should be unreachable
6+
catch case err: IllegalArgumentException =>
7+
println("Expected failure when pass Tuple3 to TupleMirror(2):")
8+
println(s"- ${err.getMessage}")
9+
10+
try
11+
val tup2b: (Int, Int) = tup2Mirror.fromProduct(Tuple(1)) // crashes with index out of bounds
12+
println(tup2b) // should be unreachable
13+
catch case err: IllegalArgumentException =>
14+
println("Expected failure when pass Tuple1 to TupleMirror(2):")
15+
println(s"- ${err.getMessage}")

0 commit comments

Comments
 (0)