source: CIVL/examples/languageFeatures/atomStatement.cvl@ aa6457c

1.23 2.0 main test-branch
Last change on this file since aa6457c was 3ff27cf, checked in by Manchun Zheng <zmanchun@…>, 11 years ago

updated examples since $assert/$assume has been changed to functions; fixed the model builder for the new side-effect remover.

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

  • Property mode set to 100644
File size: 878 bytes
RevLine 
[36b5ada]1/* Commandline execution:
2 * civl verify atomStatement.cvl
3 * */
[e6b02c8]4#include<civlc.cvh>
[10e8759]5int n = 3;
6void foo(){
[36b5ada]7 int k = n;
8 k = k + 1;
[10e8759]9}
10
11void main(){
[36b5ada]12 int i = 0;
13 int x = 3;
[48bfab9]14 $proc procs[5];
[36b5ada]15
16 $atom {
17 if(i < 0)
18 i = 1;
19 else
20 i = 2;
21 }
[3ff27cf]22 $assert((i == 2));
[36b5ada]23 $atom
24 if(i > 0)
25 i = 1;
26 else
27 i = 2;
[3ff27cf]28 $assert((i == 1));
[36b5ada]29 $atom {
30 i = 2;
31 switch(i) {
32 case 1: i = 2;
33 case 2: i = 3;break;
34 default: i = 5;
[10e8759]35 }
[36b5ada]36 }
[3ff27cf]37 $assert((i == 3));
[36b5ada]38 $atom {
39 i = 0;
40 for(int j = 0; j < 10; j++) {
41 i += j;
42 }
43 }
[3ff27cf]44 $assert((i == 45));
[36b5ada]45 $atom {
46 for(int m = 0; m < 5; m++) {
[48bfab9]47 procs[m] = $spawn foo();
[10e8759]48 }
[36b5ada]49 }
50 //nested atomic and non-pure-local atomic block
51 $atom {
52 n = 0;
53 n += 1;
54 $atom {
55 i+=2;
56 i += 3;
57 }
58 n += 9;
59 }
[3ff27cf]60 $assert((n == 10));
[48bfab9]61 for(int m = 0; m < 5; m++) {
62 $wait(procs[m]);
63 }
[10e8759]64}
Note: See TracBrowser for help on using the repository browser.