Skip to content

Commit c945ec0

Browse files
Test constant propagation of array length and cells
The test would fail if the length or cells of the array was not propagated by symex and available when deciding on which branch of the if-then-else to analyse.
1 parent 348b4f7 commit c945ec0

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
Binary file not shown.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
public class Test {
2+
3+
public String checkPass() {
4+
String string = "vVvvVvvVv";
5+
int[] array = new int[4];
6+
if(array.length == 4)
7+
{
8+
String result = string.toLowerCase();
9+
assert(result.charAt(0) == 'v');
10+
return result;
11+
}
12+
else
13+
{
14+
String result = string.toUpperCase();
15+
assert(result.charAt(0) == 'V');
16+
return result;
17+
}
18+
}
19+
20+
static public String checkPass1() {
21+
int[] array = new int[1];
22+
array[0] = 23;
23+
if(array[0] == 92)
24+
{
25+
String result = "vVvvVvvVv".toLowerCase();
26+
assert(result.charAt(0) == 'v');
27+
return result;
28+
}
29+
else
30+
{
31+
String result = "vVvvVvvVv".toUpperCase();
32+
assert(result.charAt(0) == 'V');
33+
return result;
34+
}
35+
}
36+
37+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
Test.class
3+
--function Test.checkPass --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar` --unwind 10 --show-vcc
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
cprover_string_to_lower_case_func
7+
--
8+
cprover_string_to_upper_case_func
9+
--
10+
Check that to_upper_case calls are not reached by symex, because the length is
11+
correctly propagated

0 commit comments

Comments
 (0)