Skip to content

Commit 81a4ec0

Browse files
committed
Add automatic tupling of function pameters tests
1 parent d91fa07 commit 81a4ec0

4 files changed

+67
-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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
// FIXME issue #5257
8+
// val h2: Int *: Int *: Unit => Int = (x, y) => x + y
9+
// val k2: Int *: Tuple1[Int] => Int = (x, y) => x + y
10+
11+
type T2 = Tuple2[Int, Int]
12+
val h2: T2 => Int = (x1, x2) => 2
13+
14+
val f3: Tuple3[Int, Int, Int] => Int = (x1, x2, x3) => 3
15+
val g3: Tuple3[Int, Int, Int] => Int = _ + _ + _
16+
17+
val f5: Tuple5[Int, Int, Int, Int, Int] => Int = (x1, x2, x3, x4, x5) => 5
18+
val g5: Tuple5[Int, Int, Int, Int, Int] => Int = _ + _ + _ + _ + _
19+
20+
val f10: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int] => Int =
21+
(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10) => 10
22+
val g10: Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int] => Int =
23+
_ + _ + _ + _ + _ + _ + _ + _ + _ + _
24+
25+
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 =
26+
(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22) => 22
27+
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 =
28+
_ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _
29+
30+
// FIMXE Tuples of size larger that 22 are not supported yet (issue #5256)
31+
// 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 =
32+
// (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23) => 22
33+
// 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 =
34+
// _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _ + _
35+
36+
// type T23 = (Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int)
37+
// val h23: T23 => Int = (x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23) => 23
38+
39+
}
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)