blob: 1d2d264fe753c3aaf6c2bddc8d9e413da6203c07 (
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
|
class T {
var x: int;
function use F(y: int): int {
2*y
}
method M(s: set<T>) {
use F(4);
use F(5);
assert F(5) == 10;
assert F(7) == 14; // error (definition not engaged)
}
function use G(y: int): bool {
0 <= y
}
method N(s: set<T>) {
use G(4);
use G(5);
use G(-5);
assert G(5);
assert !G(-5);
assert G(7); // error (definition not engaged)
}
function use H(): int
reads this;
{
x
}
method Q0()
modifies this;
{
var t := x;
use H();
assert H() == t;
x := x + 1;
assert old(H()) == t;
}
method Q1()
modifies this;
{
x := x + 1;
use H();
assert H() == old(H()) + 1; // error: does not know what old(H()) is
}
method Q2()
modifies this;
{
use H();
x := x + 1;
use H();
assert H() == old(H()) + 1;
}
method Q3()
modifies this;
{
x := x + 1;
use H();
use old(H());
assert H() == old(H()) + 1;
}
}
|