Skip to content

Commit 41a9a08

Browse files
committed
assert more in enum-values-order test
1 parent 93fc31c commit 41a9a08

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

tests/run/enum-values-order.scala

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
11
/** immutable hashmaps (as of 2.13 collections) only store up to 4 entries in insertion order */
22
enum LatinAlphabet { case A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z }
33

4+
enum LatinAlphabet2 extends java.lang.Enum[LatinAlphabet2] { case A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z }
5+
6+
enum LatinAlphabet3[+T] extends java.lang.Enum[LatinAlphabet3[_]] { case A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z }
7+
48
@main def Test =
5-
import LatinAlphabet._
6-
val ordered = Seq(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
79

8-
assert(ordered sameElements LatinAlphabet.values)
10+
val ordinals = Seq(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25)
11+
val labels = Seq("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z")
12+
13+
def testLatin1() =
14+
import LatinAlphabet._
15+
val ordered = Seq(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
16+
17+
assert(ordered sameElements LatinAlphabet.values)
18+
assert(ordinals == ordered.map(_.ordinal))
19+
assert(labels == ordered.map(_.productPrefix))
20+
21+
def testLatin2() =
22+
import LatinAlphabet2._
23+
val ordered = Seq(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
24+
25+
assert(ordered sameElements LatinAlphabet2.values)
26+
assert(ordinals == ordered.map(_.ordinal))
27+
assert(labels == ordered.map(_.name))
28+
29+
def testLatin3() =
30+
import LatinAlphabet3._
31+
val ordered = Seq(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z)
32+
33+
// assert(ordered sameElements LatinAlphabet3.values) // TODO: enable when .values exists on parameterized enums
34+
assert(ordinals == ordered.map(_.ordinal))
35+
assert(labels == ordered.map(_.name))
36+
37+
testLatin1()

0 commit comments

Comments
 (0)