Skip to content

Commit 29f4c17

Browse files
committed
Add IndexOutOfBounds Tests
1 parent 589437b commit 29f4c17

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package testSuite.classes.index_out_of_bounds_correct;
2+
3+
import liquidjava.specification.ExternalRefinementsFor;
4+
import liquidjava.specification.Ghost;
5+
import liquidjava.specification.Refinement;
6+
import liquidjava.specification.StateRefinement;
7+
8+
@ExternalRefinementsFor("java.util.ArrayList")
9+
@Ghost("int size")
10+
public interface ArrayListRefinements<E> {
11+
12+
public void ArrayList();
13+
14+
@StateRefinement(to = "size(this) == size(old(this)) + 1")
15+
public boolean add(E elem);
16+
17+
public E get(@Refinement("_ < size(this)") int index);
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package testSuite.classes.index_out_of_bounds_correct;
2+
3+
import java.util.ArrayList;
4+
5+
public class Test {
6+
public static void main(String[] args) {
7+
ArrayList<Integer> l = new ArrayList<>();
8+
l.add(1);
9+
l.get(0);
10+
}
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package testSuite.classes.index_out_of_bounds_error;
2+
3+
import liquidjava.specification.ExternalRefinementsFor;
4+
import liquidjava.specification.Ghost;
5+
import liquidjava.specification.Refinement;
6+
import liquidjava.specification.StateRefinement;
7+
8+
@ExternalRefinementsFor("java.util.ArrayList")
9+
@Ghost("int size")
10+
public interface ArrayListRefinements<E> {
11+
12+
public void ArrayList();
13+
14+
@StateRefinement(to = "size(this) == size(old(this)) + 1")
15+
public boolean add(E elem);
16+
17+
public E get(@Refinement("_ < size(this)") int index);
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package testSuite.classes.index_out_of_bounds_error;
2+
3+
import java.util.ArrayList;
4+
5+
public class Test {
6+
public static void main(String[] args) {
7+
ArrayList<Integer> l = new ArrayList<>();
8+
l.get(0); // index out of bounds
9+
}
10+
}

0 commit comments

Comments
 (0)