1.23
2.0
main
test-branch
|
Last change
on this file since f3527dd 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
|
| Line | |
|---|
| 1 | /* Commandline execution:
|
|---|
| 2 | * civl verify atomStatement.cvl
|
|---|
| 3 | * */
|
|---|
| 4 | #include<civlc.cvh>
|
|---|
| 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 | $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.