Skip to content

Commit ab7d097

Browse files
Add a test
1 parent fe7ace0 commit ab7d097

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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 = 3int;
17+
let y = add(x, 5int);
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(2int);
40+
let l1 = s.len();
41+
proof_assert!(l1 == s.len());
42+
s.0.push_back_ghost(4int);
43+
let l2 = s.len();
44+
proof_assert!(l2 == s.len());
45+
};
46+
}

0 commit comments

Comments
 (0)