summaryrefslogtreecommitdiff
path: root/Test/og/foo.bpl
blob: 5ddc75c0580824ca448ec167d4ebc11ffeb8af34 (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
// RUN: %boogie -noinfer "%s" > "%t"
// RUN: %diff "%s.expect" "%t"
var {:phase 1} g:int;

procedure {:yields} {:phase 1} PB()
{
  yield;
  call Incr();
  yield;
}

procedure {:yields} {:phase 0,1} Incr();
ensures {:atomic}
|{A:
  g := g + 1; return true;
}|;

procedure {:yields} {:phase 0,1} Set(v: int);
ensures {:atomic}
|{A:
  g := v; return true;
}|;

procedure {:yields} {:phase 1} PC()
ensures {:phase 1} g == 3;
{
  yield;
  call Set(3);
  yield;
  assert {:phase 1} g == 3;
}

procedure {:yields} {:phase 1} PE()
{
  call PC();
}

procedure {:yields} {:phase 1} PD()
{
  call PC();
  assert {:phase 1} g == 3;
}

procedure {:yields} {:phase 1} Main()
{
  yield;
  while (*)
  {
    yield;
    async call PB();
    yield;
    async call PE();
    yield;
    async call PD();
    yield;
  }
}