forked from verus-lang/verus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathno_cheating.rs
More file actions
107 lines (94 loc) · 2.96 KB
/
no_cheating.rs
File metadata and controls
107 lines (94 loc) · 2.96 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#![feature(rustc_private)]
#[macro_use]
mod common;
use common::*;
test_verify_one_file_with_options! {
#[test] test_no_cheating_external_body ["--no-cheating"] => verus_code! {
#[verifier::external_body] fn no_good() // FAILS
{}
} => Err(e) => assert_one_fails(e)
}
test_verify_one_file_with_options! {
#[test] test_no_cheating_external_body_trait ["--no-cheating"] => verus_code! {
trait A {
#[verifier::external_body] fn no_good(&self) // FAILS
{}
}
} => Err(e) => assert_one_fails(e)
}
test_verify_one_file_with_options! {
#[test] test_no_cheating_external_body_trait_impl ["--no-cheating"] => verus_code! {
trait A {
fn no_good(&self) {}
}
struct S;
impl A for S {
#[verifier::external_body] fn no_good(&self) // FAILS
{}
}
} => Err(e) => assert_one_fails(e)
}
test_verify_one_file_with_options! {
#[test] test_no_cheating_assume ["--no-cheating"] => verus_code! {
proof fn test() {
assume(1 + 1 == 3); // FAILS
}
} => Err(e) => assert_one_fails(e)
}
test_verify_one_file_with_options! {
#[test] test_no_cheating_admit ["--no-cheating"] => verus_code! {
proof fn test() {
admit(); // FAILS
}
} => Err(e) => assert_one_fails(e)
}
test_verify_one_file_with_options! {
#[test] test_no_cheating_assume_proof_block ["--no-cheating"] => verus_code! {
fn test() {
proof {
assume(1 + 1 == 3); // FAILS
}
}
} => Err(e) => assert_one_fails(e)
}
test_verify_one_file_with_options! {
#[test] test_no_cheating_admit_proof_block ["--no-cheating"] => verus_code! {
fn test() {
proof {
admit(); // FAILS
}
}
} => Err(e) => assert_one_fails(e)
}
test_verify_one_file_with_options! {
#[test] test_no_cheating_assume_spec ["--no-cheating"] => verus_code! {
use vstd::prelude::*;
pub assume_specification<T, U> [Option::<(T, U)>::unzip](a: Option<(T, U)>) // FAILS
-> (r: (Option<T>, Option<U>))
ensures false
;
} => Err(e) => assert_one_fails(e)
}
test_verify_one_file_with_options! {
#[test] test_no_cheating_via_fn ["--no-cheating", "--no-verify"] => verus_code! {
spec fn up(i: int) -> int
decreases i via no_good
{
up(i + 1)
}
#[verifier::external_body]
#[via_fn]
proof fn no_good(i: int) // FAILS
{}
} => Err(e) => assert_one_fails(e)
}
test_verify_one_file_with_options! {
#[test] test_no_cheating_admit_exec_allows_no_decreases_clause ["--no-cheating"] => verus_code! {
#[verifier::assume_termination]
fn a(mut i: u64)
requires i <= 10,
{
a(i)
}
} => Err(err) => assert_vir_error_msg(err, "#[verifier::assume_termination] not allowed with --no-cheating")
}