Skip to content

Commit 9b37a7c

Browse files
committed
New and updated tests
1 parent a46f4f8 commit 9b37a7c

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

tests/neg/enums.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ enum class X {
88
}
99

1010
enum E1[T] {
11-
case C
11+
case C // error: cannot determine type argument
1212
}
1313

1414
enum E2[+T, +U >: T] {
15-
case C
15+
case C // error: cannot determine type argument
1616
}
1717

1818
enum E3[-T <: Ordered[T]] {
19-
case C
19+
case C // error: cannot determine type argument
2020
}

tests/run/enum-List2a.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
enum class List[+T]
2+
object List {
3+
case Cons(x: T, xs: List[T])
4+
case Nil
5+
}
6+
object Test {
7+
import List._
8+
val xs = Cons(1, Cons(2, Cons(3, Nil)))
9+
def main(args: Array[String]) = println(xs)
10+
}
11+

tests/run/enum-approx.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
enum class Fun[-T, +U >: Null] {
2+
def f: T => U = null
3+
}
4+
object Fun {
5+
case Identity[T, U >: Null](override val f: T => U) extends Fun[T, U]
6+
case ConstNull {
7+
override def f = x => null
8+
}
9+
case ConstNullClass() {
10+
override def f = x => null
11+
}
12+
case ConstNullSimple
13+
}
14+
15+
object Test {
16+
def main(args: Array[String]) = {
17+
val x: Null = Fun.ConstNull.f("abc")
18+
val y: Null = Fun.ConstNullClass().f("abc")
19+
assert(Fun.ConstNullSimple.f == null)
20+
}
21+
}
22+

tests/run/enumList2a.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Cons(1,Cons(2,Cons(3,Nil)))

0 commit comments

Comments
 (0)