Skip to content

Commit 3b93d98

Browse files
liufengyunallanrenucci
authored andcommitted
add more tests
1 parent 4c12ed3 commit 3b93d98

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/run/i4984d.scala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
object Array2 {
2+
def unapplySeq(x: Array[Int]): Data1 = new Data1
3+
4+
class Data1 {
5+
def isEmpty: Boolean = false
6+
def get: Data2 = new Data2
7+
}
8+
9+
class Data2 {
10+
def apply(i: Int): Int = 3
11+
def drop(n: Int): scala.Seq[Int] = Seq(2, 5)
12+
def toSeq: scala.Seq[Int] = Seq(6, 7)
13+
def lengthCompare(len: Int): Int = 0
14+
}
15+
}
16+
17+
object Test {
18+
def test1(xs: Array[Int]): Int = xs match {
19+
case Array2(x, y) => x + y
20+
}
21+
22+
def test2(xs: Array[Int]): Seq[Int] = xs match {
23+
case Array2(x, y, xs:_*) => xs
24+
}
25+
26+
def test3(xs: Array[Int]): Seq[Int] = xs match {
27+
case Array2(xs:_*) => xs
28+
}
29+
30+
def main(args: Array[String]): Unit = {
31+
test1(Array(3, 5))
32+
test2(Array(3, 5))
33+
test3(Array(3, 5))
34+
}
35+
}

0 commit comments

Comments
 (0)