Skip to content

Commit f2e9c22

Browse files
Add tests for boolean constant propagation in java
Check that symex can resolve what value a boolean takes after a condition which means that it can only take one value
1 parent 6d8b42a commit f2e9c22

12 files changed

+171
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
class Test {
2+
static public void noComparison(boolean my_boolean) {
3+
if (my_boolean)
4+
assert (my_boolean == true);
5+
}
6+
7+
static public void notNoComparison(boolean my_boolean) {
8+
if (!my_boolean)
9+
assert (my_boolean == false);
10+
}
11+
12+
static public void equalsTrue(boolean my_boolean) {
13+
if (my_boolean == true)
14+
assert (my_boolean == true);
15+
}
16+
17+
static public void equalsFalse(boolean my_boolean) {
18+
if (my_boolean == false)
19+
assert (my_boolean == false);
20+
}
21+
22+
static public void notEqualsTrue(boolean my_boolean) {
23+
if (!(my_boolean == true))
24+
assert (my_boolean == false);
25+
}
26+
27+
static public void notEqualsFalse(boolean my_boolean) {
28+
if (!(my_boolean == false))
29+
assert (my_boolean == true);
30+
}
31+
32+
static public void disequalsTrue(boolean my_boolean) {
33+
if (my_boolean != true)
34+
assert (my_boolean == false);
35+
}
36+
37+
static public void disequalsFalse(boolean my_boolean) {
38+
if (my_boolean != false)
39+
assert (my_boolean == true);
40+
}
41+
42+
static public void notDisequalsTrue(boolean my_boolean) {
43+
if (!(my_boolean != true))
44+
assert (my_boolean == true);
45+
}
46+
47+
static public void notDisequalsFalse(boolean my_boolean) {
48+
if (!(my_boolean != false))
49+
assert (my_boolean == false);
50+
}
51+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.disequalsFalse
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.disequalsTrue
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.equalsFalse
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.equalsTrue
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.noComparison
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.notDisequalsFalse
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.notDisequalsFalse
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.notEqualsFalse
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.notEqualsTrue
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--function Test.notNoComparison
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
0 remaining after simplification$
8+
--
9+
^warning: ignoring
10+
--
11+
Assumption and GOTO condition propagation means this test should be
12+
entirely decided by symex.

0 commit comments

Comments
 (0)