-
Notifications
You must be signed in to change notification settings - Fork 82
/
Copy pathproph.rs
68 lines (58 loc) · 1.53 KB
/
proph.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#![feature(rustc_private)]
#[macro_use]
mod common;
use common::*;
test_verify_one_file! {
#[test] prophecy_expected_use_1 verus_code! {
use vstd::proph::*;
fn test_bool() {
let ghost x: int = 1;
let p = Prophecy::<bool>::new();
proof {
if p@ {
x = 2;
} else {
x = 3;
}
}
p.resolve(&true);
assert(x == 2);
}
} => Ok(())
}
test_verify_one_file! {
#[test] prophecy_expected_use_2 verus_code! {
use vstd::proph::*;
#[derive(PartialEq, Eq, Structural)]
struct S {
a: u64,
b: u8,
c: bool,
}
fn test() {
let p = Prophecy::<S>::new();
p.resolve(&S{a: 1u64, b: 2u8, c: false});
assert(p@ == S{a: 1u64, b: 2u8, c: false});
}
} => Ok(())
}
test_verify_one_file! {
#[test] prophecy_expected_use_3 verus_code! {
use vstd::proph::*;
fn test() {
let p = Prophecy::<bool>::new();
p.resolve(&true);
assert(p@ == true);
}
} => Ok(())
}
test_verify_one_file! {
#[test] prophecy_ghost_disallowed verus_code! {
use vstd::proph::*;
fn test() {
let p = Prophecy::<Ghost<bool>>::new();
p.resolve(&Ghost(!p.view().view()));
assert(false);
}
} => Err(err) => assert_rust_error_msg(err, "trait bounds were not satisfied")
}