blob: 4afbb99ef79b5ce576c5847325b80f16f4618e4c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
object Q extends Enumeration {
val A = Value("A")
val B = Value("B")
val C = Value("C")
}
object R extends Enumeration {
val A, B, C = Value
}
object Test extends App {
assert(Q(0) == Q.withName("A"))
assert(Q.C == Q.withName("C"))
assert(R(0) == R.withName("A"))
assert(R.C == R.withName("C"))
var failed = false
try { Q.withName("x") } catch { case _: NoSuchElementException => failed = true }
assert(failed)
}
|