Skip to content

Commit fe41aa9

Browse files
Add tests for the use of string dependencies
This tests, check that only constraints for the string operation that matters are added to the list of axioms of the string solver. In the example added here, the solver would previously consider 11 constraints, but now only 3, and still finds the correct result.
1 parent fddebda commit fe41aa9

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Test {
2+
void test(String s) {
3+
// Filter
4+
if(s == null)
5+
return;
6+
7+
// Act
8+
9+
// this matters for the final test
10+
String t = s.concat("_foo");
11+
12+
// these should be ignored by the solver as they
13+
// do not matter for the final test
14+
String u = s.concat("_bar");
15+
String v = s.concat("_baz");
16+
String w = s.concat("_fiz");
17+
String x = s.concat("_buz");
18+
19+
// Assert
20+
assert t.endsWith("foo");
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Test.class
3+
--refine-strings --string-max-length 1000 --string-max-input-length 100 --verbosity 10 Test.class --function Test.test
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
assertion at file Test.java line 20 .*: SUCCESS
7+
string_refinement::check_axioms: 3 universal axioms
8+
--
9+
--
10+
We check there are exactly 3 universal formulas considered by the solver (2 for
11+
`t = s.concat("_foo")` and 1 for `t.endsWith("foo")`).
12+
The other concatenations should be ignored.

0 commit comments

Comments
 (0)