blob: 2b892b3595a74bbdb155f5cb7c5aacd39607552b (
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
|
// RUN: %dafny "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
class C {
static function method Static() : bool
{
true
}
}
method K() {
var f := C.Static;
var o : object;
assert o !in f.reads();
assert f.requires();
assert f();
}
class T {
var h : int -> int;
}
function B(t : T) : int -> int
requires t != null;
reads t;
{
t.h
}
function J(t : T) : int
requires t != null;
requires t.h.reads(0) == {};
reads t;
reads if t != null then t.h.reads(0) else {};
{
if t.h.requires(0) then
B(t)(0)
else
B(t)(0) // fail
}
method U(t : T)
requires t != null;
modifies t;
{
t.h := x => x;
assert J(t) == 0; // ok
}
|