source: CIVL/examples/mem/readset/conditional.cvl

main
Last change on this file was 7fd829c, checked in by Stephen Siegel <siegel@…>, 2 years ago

Fix the bug that guards were not recorded in read set

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5886 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[7fd829c]1#include<mem.cvh>
2
3int test1() {
4 int x,y,z;
5 int p;
6
7 x = 0, y = 0, z = 0;
8 $havoc(&p);
9 $read_set_push();
10
11 p ? x : y;
12
13 $mem m = $read_set_pop();
14
15 $assert($mem_contains(m, &p));
16 $assert($mem_contains(m, &x) || $mem_contains(m, &y));
17}
18
19int test2() {
20 int x,y,z;
21 int p;
22
23 x = 0, y = 0, z = 0;
24 $havoc(&p);
25 $read_set_push();
26
27 if (p)
28 x;
29 else
30 y;
31
32 $mem m = $read_set_pop();
33
34 $assert($mem_contains(m, &p));
35 $assert($mem_contains(m, &x) || $mem_contains(m, &y));
36}
37
38int test3() {
39 int x,y,z;
40 int p;
41
42 x = 0, y = 0, z = 0;
43 $havoc(&p);
44 $read_set_push();
45
46 do {
47 x;
48 } while (p);
49 y;
50 $mem m = $read_set_pop();
51 $mem oracle = ($mem)&x;
52
53 oracle = $mem_union(oracle, ($mem)&y);
54 oracle = $mem_union(oracle, ($mem)&p);
55 $assert($mem_equals(m, oracle));
56}
57
58int test4() {
59 int x,y,z;
60 int p;
61
62 x = 0, y = 0, z = 0;
63 $havoc(&p);
64 $read_set_push();
65
66 switch(p) {
67 case 1:
68 x;
69 break;
70 case 2:
71 y;
72 break;
73 default:
74 z;
75 break;
76 }
77
78 $mem m = $read_set_pop();
79
80 $assert($mem_contains(m, &p));
81 $assert($mem_contains(m, &x) || $mem_contains(m, &y) ||
82 $mem_contains(m, &z));
83}
84
85int main() {
86 test1();
87 test2();
88 test3();
89}
Note: See TracBrowser for help on using the repository browser.