File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ extern crate creusot_contracts;
2+ use creusot_contracts:: * ;
3+
4+ #[ has_logical_alias( add_logic) ]
5+ #[ check( ghost) ]
6+ fn add ( x : Int , y : Int ) -> Int {
7+ x + y
8+ }
9+ #[ logic]
10+ fn add_logic ( x : Int , y : Int ) -> Int {
11+ x + y
12+ }
13+
14+ pub fn test_add ( ) {
15+ ghost ! {
16+ let x = 3 int;
17+ let y = add( x, 5 int) ;
18+ proof_assert!( y == add( x, 5 ) ) ;
19+ } ;
20+ }
21+
22+ struct Seq2 < T > ( Seq < T > ) ;
23+
24+ impl < T > Seq2 < T > {
25+ #[ has_logical_alias( Self :: len_logic) ]
26+ #[ check( ghost) ]
27+ fn len ( & self ) -> Int {
28+ self . 0 . len_ghost ( )
29+ }
30+ #[ logic]
31+ fn len_logic ( & self ) -> Int {
32+ self . 0 . len ( )
33+ }
34+ }
35+
36+ pub fn test_seq ( ) {
37+ ghost ! {
38+ let mut s = Seq2 ( Seq :: new( ) . into_inner( ) ) ;
39+ s. 0 . push_back_ghost( 2 int) ;
40+ let l1 = s. len( ) ;
41+ proof_assert!( l1 == s. len( ) ) ;
42+ s. 0 . push_back_ghost( 4 int) ;
43+ let l2 = s. len( ) ;
44+ proof_assert!( l2 == s. len( ) ) ;
45+ } ;
46+ }
You can’t perform that action at this time.
0 commit comments