Skip to content

Commit 899b1ee

Browse files
committed
Add test for nondet initialization of enums
1 parent e6fa938 commit 899b1ee

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed
892 Bytes
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
public enum Color {
2+
RED,
3+
GREEN,
4+
BLUE
5+
}
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class NondetEnumArg {
2+
3+
public static Color test(Color c) {
4+
if (c == null)
5+
return c;
6+
assert c != null;
7+
boolean isRed = c.name().startsWith("RED") && c.name().length() == 3
8+
&& c.ordinal() == 0;
9+
boolean isGreen = c.name().startsWith("GREEN") && c.name().length() == 5
10+
&& c.ordinal() == 1;
11+
boolean isBlue = c.name().startsWith("BLUE") && c.name().length() == 4
12+
&& c.ordinal() == 2;
13+
assert (isRed || isGreen || isBlue);
14+
return c;
15+
}
16+
17+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
NondetEnumArg.class
3+
--function NondetEnumArg.test --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar`
4+
^VERIFICATION SUCCESSFUL$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
--
9+
The test checks that the name and ordinal fields of nondet-initialized enums
10+
correspond to those of an enum constant of the same type.

0 commit comments

Comments
 (0)