source: CIVL/examples/languageFeatures/civlValueUndefined.cvl@ 51a0c37

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since 51a0c37 was 51a0c37, checked in by Ziqing Luo <ziqing@…>, 11 years ago

add an exmaple to cover "isValueDefined" function

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

  • Property mode set to 100644
File size: 752 bytes
Line 
1/* civlValueUndefined : This example lists several cases of misusage of
2 $scope, $proc and pointer types. It is used for code coverage, so
3 the program may not meaningful. */
4#include<civlc.cvh>
5#include<stdlib.h>
6$scope scope;
7double * ptr;
8void getInvalidScope() {
9 scope = $here;
10 ptr = (double*)malloc(sizeof(double));
11 free(ptr);
12}
13
14int main() {
15 $scope root = $root;
16 $proc proc0, proc1;
17 int a = 0;
18
19 proc0 = $spawn getInvalidScope();
20 $wait(proc0);
21 proc1 = proc0;
22 //so far, scope, proc0 and proc1 are all undefined; ptr is to a
23 //memory space which belongs to an undefined scope.
24 $choose{
25 $when($true) {a = scope == root;}
26 $when($true) {a = proc0 == proc1;}
27 $when($true) {a = ptr == (void*)0;}
28 }
29 return 0;
30}
Note: See TracBrowser for help on using the repository browser.