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

1.23 2.0 main test-branch
Last change on this file since ac43965 was d980649, checked in by Manchun Zheng <zmanchun@…>, 10 years ago

fixed extra parenthesis.

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

  • Property mode set to 100644
File size: 868 bytes
Line 
1/* Commandline execution:
2 * civl verify atomStatement.cvl
3 * */
4#include<civlc.cvh>
5int n = 3;
6void foo(){
7 int k = n;
8 k = k + 1;
9}
10
11void main(){
12 int i = 0;
13 int x = 3;
14 $proc procs[5];
15
16 $atom {
17 if(i < 0)
18 i = 1;
19 else
20 i = 2;
21 }
22 $assert(i == 2);
23 $atom
24 if(i > 0)
25 i = 1;
26 else
27 i = 2;
28 $assert(i == 1);
29 $atom {
30 i = 2;
31 switch(i) {
32 case 1: i = 2;
33 case 2: i = 3;break;
34 default: i = 5;
35 }
36 }
37 $assert(i == 3);
38 $atom {
39 i = 0;
40 for(int j = 0; j < 10; j++) {
41 i += j;
42 }
43 }
44 $assert(i == 45);
45 $atom {
46 for(int m = 0; m < 5; m++) {
47 procs[m] = $spawn foo();
48 }
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 }
60 $assert(n == 10);
61 for(int m = 0; m < 5; m++) {
62 $wait(procs[m]);
63 }
64}
Note: See TracBrowser for help on using the repository browser.