File tree Expand file tree Collapse file tree 4 files changed +57
-0
lines changed
liquidjava-example/src/main/java/testSuite/classes
index_out_of_bounds_correct
index_out_of_bounds_error Expand file tree Collapse file tree 4 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments