blob: a873a4e672f8cd6f84837040fb638ec2637483c3 (
plain)
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
|
// Test the implementation of free calls. These calls don't check the preconditions of the
// called procedure in the caller.
procedure Uncallable(i: int)
requires 0 <= i;
free requires true;
requires false;
{
}
procedure UncallableReturn(i: int) returns (b: bool)
requires 0 <= i;
free requires true;
requires false;
{
b := true;
}
function T(b: bool) : bool
{
b == true
}
procedure TestCallForall(b: bool)
requires T(b);
free requires true;
ensures T(b);
{
}
procedure NormalCall0()
{
call Uncallable(0); // error: precondition violation
}
procedure NormalCall1()
{
call Uncallable(-1); // error: precondition violation
}
procedure FreeCall0()
{
free call Uncallable(0);
}
procedure FreeCall1()
{
free call Uncallable(-1);
}
procedure NormalCall2()
{
var b: bool;
call b := UncallableReturn(0); // error: precondition violation
}
procedure NormalCall3()
{
var b: bool;
call b := UncallableReturn(-1); // error: precondition violation
}
procedure FreeCall3()
{
var b: bool;
free call b := UncallableReturn(0);
}
procedure FreeCall4()
{
var b: bool;
free call b := UncallableReturn(-1);
}
|