1.23
2.0
main
test-branch
|
Last change
on this file since e5c6156 was 09b9231b, checked in by Manchun Zheng <zmanchun@…>, 12 years ago |
|
implemented assert statements with printing functionality; since $assert is redefined as a function in civlc.h, the translation in FunctionTranslator is changed and all examples using $assert is updated accordingly; translates assert() which is defined in assert.h into an assert statement; fixed warnings in mpi executor.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@536 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
781 bytes
|
| Line | |
|---|
| 1 | /* Commandline execution:
|
|---|
| 2 | * civl verify atomStatement.cvl
|
|---|
| 3 | * */
|
|---|
| 4 | #include<civlc.h>
|
|---|
| 5 | int n = 3;
|
|---|
| 6 | void foo(){
|
|---|
| 7 | int k = n;
|
|---|
| 8 | k = k + 1;
|
|---|
| 9 | }
|
|---|
| 10 |
|
|---|
| 11 | void main(){
|
|---|
| 12 | int i = 0;
|
|---|
| 13 | int x = 3;
|
|---|
| 14 |
|
|---|
| 15 | $atom {
|
|---|
| 16 | if(i < 0)
|
|---|
| 17 | i = 1;
|
|---|
| 18 | else
|
|---|
| 19 | i = 2;
|
|---|
| 20 | }
|
|---|
| 21 | $assert(i == 2);
|
|---|
| 22 | $atom
|
|---|
| 23 | if(i > 0)
|
|---|
| 24 | i = 1;
|
|---|
| 25 | else
|
|---|
| 26 | i = 2;
|
|---|
| 27 | $assert(i == 1);
|
|---|
| 28 | $atom {
|
|---|
| 29 | i = 2;
|
|---|
| 30 | switch(i) {
|
|---|
| 31 | case 1: i = 2;
|
|---|
| 32 | case 2: i = 3;break;
|
|---|
| 33 | default: i = 5;
|
|---|
| 34 | }
|
|---|
| 35 | }
|
|---|
| 36 | $assert(i == 3);
|
|---|
| 37 | $atom {
|
|---|
| 38 | i = 0;
|
|---|
| 39 | for(int j = 0; j < 10; j++) {
|
|---|
| 40 | i += j;
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 | $assert(i == 45);
|
|---|
| 44 | $atom {
|
|---|
| 45 | for(int m = 0; m < 5; m++) {
|
|---|
| 46 | $spawn foo();
|
|---|
| 47 | }
|
|---|
| 48 | }
|
|---|
| 49 | //nested atomic and non-pure-local atomic block
|
|---|
| 50 | $atom {
|
|---|
| 51 | n = 0;
|
|---|
| 52 | n += 1;
|
|---|
| 53 | $atom {
|
|---|
| 54 | i+=2;
|
|---|
| 55 | i += 3;
|
|---|
| 56 | }
|
|---|
| 57 | n += 9;
|
|---|
| 58 | }
|
|---|
| 59 | $assert(n == 10);
|
|---|
| 60 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.