File tree 8 files changed +82
-0
lines changed
jbmc/regression/jbmc/NondetEnumArg
8 files changed +82
-0
lines changed Original file line number Diff line number Diff line change
1
+ public enum Color {
2
+ RED ,
3
+ GREEN ,
4
+ BLUE
5
+ }
Original file line number Diff line number Diff line change
1
+ public class NondetEnumArg {
2
+
3
+ public static void canChooseSomeConstant (Color c ) {
4
+ if (c == null )
5
+ return ;
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
+ }
15
+
16
+ public static void canChooseRed (Color c ) {
17
+ if (c == null )
18
+ return ;
19
+ boolean isGreen = c .name ().startsWith ("GREEN" ) && c .name ().length () == 5
20
+ && c .ordinal () == 1 ;
21
+ boolean isBlue = c .name ().startsWith ("BLUE" ) && c .name ().length () == 4
22
+ && c .ordinal () == 2 ;
23
+ assert (isGreen || isBlue );
24
+ }
25
+
26
+ public static void canChooseGreen (Color c ) {
27
+ if (c == null )
28
+ return ;
29
+ boolean isRed = c .name ().startsWith ("RED" ) && c .name ().length () == 3
30
+ && c .ordinal () == 0 ;
31
+ boolean isBlue = c .name ().startsWith ("BLUE" ) && c .name ().length () == 4
32
+ && c .ordinal () == 2 ;
33
+ assert (isRed || isBlue );
34
+ }
35
+
36
+ public static void canChooseBlue (Color c ) {
37
+ if (c == null )
38
+ return ;
39
+ boolean isRed = c .name ().startsWith ("RED" ) && c .name ().length () == 3
40
+ && c .ordinal () == 0 ;
41
+ boolean isGreen = c .name ().startsWith ("GREEN" ) && c .name ().length () == 5
42
+ && c .ordinal () == 1 ;
43
+ assert (isRed || isGreen );
44
+ }
45
+
46
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ NondetEnumArg.class
3
+ --function NondetEnumArg.canChooseSomeConstant --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.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ NondetEnumArg.class
3
+ --function NondetEnumArg.canChooseRed --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar`
4
+ ^VERIFICATION FAILED$
5
+ --
6
+ --
7
+ Test 1 of 3 to check that any of the enum constants can be chosen.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ NondetEnumArg.class
3
+ --function NondetEnumArg.canChooseGreen --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar`
4
+ ^VERIFICATION FAILED$
5
+ --
6
+ --
7
+ Test 2 of 3 to check that any of the enum constants can be chosen.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ NondetEnumArg.class
3
+ --function NondetEnumArg.canChooseBlue --cp `../../../../scripts/format_classpath.sh . ../../../src/java_bytecode/library/core-models.jar`
4
+ ^VERIFICATION FAILED$
5
+ --
6
+ --
7
+ Test 3 of 3 to check that any of the enum constants can be chosen.
You can’t perform that action at this time.
0 commit comments