Skip to content

Commit 608f8a5

Browse files
committed
Add automatic tupling of function pameters tests
1 parent d91fa07 commit 608f8a5

4 files changed

+55
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
object Test {
3+
4+
val f1: Tuple1[Int] => Int = (x: Int) => x // error
5+
val g1: Tuple1[Int] => Int = _ // error
6+
7+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
object Test {
3+
4+
val f2: Tuple2[Int, String] => Int = (x, y) => x
5+
val g2: Tuple2[Int, String] => Int = _ + _.length
6+
7+
val f3: Tuple3[Int, Int, Int] => Int = (x1, x2, x3) => 3
8+
val g3: Tuple3[Int, Int, Int] => Int = _ + _ + _
9+
10+
val f5: Tuple5[Int, Int, Int, Int, Int] => Int = (x1, x2, x3, x4, x5) => 5
11+
val g5: Tuple5[Int, Int, Int, Int, Int] => Int = _ + _ + _ + _ + _
12+
13+
val f10: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int] => Int =
14+
(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) => 10
15+
val g10: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int] => Int =
16+
_ + _ + _ + _ + _ + _ + _ + _ + _ + _
17+
18+
val f22: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int] => Int =
19+
(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22) => 22
20+
val g22: Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int] => Int =
21+
_ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _
22+
23+
// FIMXE Tuples of size larger that 22 are not supported yet (issue #5256)
24+
// val f23: ((Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)) => Int = (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23) => 22
25+
// val g23: ((Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)) => Int = _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _
26+
27+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
List(3, 7, 11)
2+
List(3, 7, 11)
3+
List(3, 7, 11)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
object Test {
3+
4+
def main(args: Array[String]): Unit = {
5+
val xs: List[(Int, Int)] = (1, 2) :: (3, 4) :: (5, 6) :: Nil
6+
7+
println(xs.map {
8+
case (x, y) => x + y
9+
})
10+
11+
println(xs.map {
12+
(x, y) => x + y
13+
})
14+
15+
println(xs.map(_ + _))
16+
}
17+
18+
}

0 commit comments

Comments
 (0)