Skip to content

Commit e56041f

Browse files
committed
Add String.substring() and StringBuilder.substring() regression error tests
Add regression tests that check that the constant propagator does not simplify substring() invocations with only constant arguments when the indices are out of bounds.
1 parent 8f9a9c7 commit e56041f

File tree

10 files changed

+101
-0
lines changed

10 files changed

+101
-0
lines changed
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class Main {
2+
public void test1() {
3+
StringBuilder sb = new StringBuilder("abc");
4+
sb.substring(-1);
5+
}
6+
7+
public void test2() {
8+
StringBuilder sb = new StringBuilder("abc");
9+
sb.substring(4);
10+
}
11+
12+
public void test3() {
13+
StringBuilder sb = new StringBuilder("abc");
14+
sb.substring(-1, 4);
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FUTURE
2+
Main.class
3+
--function Main.test1 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [1-9][0-9]* VCC\(s\), 1 remaining after simplification$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
no uncaught exception: FAILURE
8+
^VERIFICATION FAILED$
9+
--
10+
--
11+
This test will pass once a model for StringBuilder.substring() exists that
12+
throws an exception when the index is greater or equal to the length of the
13+
string.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FUTURE
2+
Main.class
3+
--function Main.test2 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [1-9][0-9]* VCC\(s\), 1 remaining after simplification$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
no uncaught exception: FAILURE
8+
^VERIFICATION FAILED$
9+
--
10+
--
11+
This test will pass once a model for StringBuilder.substring() exists that
12+
throws an exception when the index is greater or equal to the length of the
13+
string.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FUTURE
2+
Main.class
3+
--function Main.test3 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [1-9][0-9]* VCC\(s\), 1 remaining after simplification$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
no uncaught exception: FAILURE
8+
^VERIFICATION FAILED$
9+
--
10+
--
11+
This test will pass once a model for StringBuilder.substring() exists that
12+
throws an exception when the index is greater or equal to the length of the
13+
string.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class Main {
2+
public void test1() {
3+
String s1 = "abc";
4+
s1.substring(-1);
5+
}
6+
7+
public void test2() {
8+
String s1 = "abc";
9+
s1.substring(4);
10+
}
11+
12+
public void test3() {
13+
String s1 = "abc";
14+
s1.substring(-1, 4);
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Main.class
3+
--function Main.test1 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [1-9][0-9]* VCC\(s\), 1 remaining after simplification$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
no uncaught exception: FAILURE
8+
^VERIFICATION FAILED$
9+
--
10+
--
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Main.class
3+
--function Main.test2 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [1-9][0-9]* VCC\(s\), 1 remaining after simplification$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
no uncaught exception: FAILURE
8+
^VERIFICATION FAILED$
9+
--
10+
--
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE
2+
Main.class
3+
--function Main.test3 --cp `../../../../scripts/format_classpath.sh . ../../../lib/java-models-library/target/core-models.jar`
4+
^Generated [1-9][0-9]* VCC\(s\), 1 remaining after simplification$
5+
^EXIT=10$
6+
^SIGNAL=0$
7+
no uncaught exception: FAILURE
8+
^VERIFICATION FAILED$
9+
--
10+
--

0 commit comments

Comments
 (0)