source: CIVL/examples/arrayLambda/arrayLambdaCompoundLiterals2.cvl@ e2570cd

main test-branch
Last change on this file since e2570cd was 1b85498, checked in by Stephen Siegel <siegel@…>, 14 months ago

Support for non-const struct literal expressions in CIVL model

StructOrUnionLiterals and ArrayLiterals are now all represented by CompoundLiterals

(https://vsl.cis.udel.edu/trac/civl/ticket/969)

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

  • Property mode set to 100644
File size: 1.3 KB
Line 
1$input int n;
2$assume(n > 0);
3
4typedef struct {
5 int x;
6 float y;
7} simple_t;
8
9typedef struct {
10 int x;
11 float y;
12 simple_t t;
13 union {
14 simple_t t;
15 int x;
16 } u;
17 int ts[10];
18} complex_t;
19
20
21int main() {
22 complex_t s[n] = (complex_t[n])$lambda(int i) (complex_t){42, .9};
23
24 $assert($forall (int i : 0 .. n-1) s[i].x == 42 && s[i].y == 0.9 &&
25 s[i].t.x == 0 && s[i].t.y == 0 &&
26 s[i].u.t.x == 0 && s[i].u.t.y == 0);
27 $assert($forall (int i : 0 .. n-1) $forall (int j : 0 .. 9) s[i].ts[j] == 0);
28
29 complex_t s2[n] = (complex_t[n])$lambda(int i) (complex_t){.y = .9, .x = 42, .t = {42, .9},
30 /* .u = */ {42}, {1,2,3}};
31
32 $assert($forall (int i : 0 .. n-1) s2[i].x == 42 && s2[i].y == 0.9 &&
33 s2[i].t.x == 42 && s2[i].t.y == 0.9 &&
34 s2[i].u.t.x == 42 && s2[i].u.t.y == 0);
35 $assert($forall (int i : 0 .. n-1) s2[i].ts[0] == 1 && s2[i].ts[1] == 2 && s2[i].ts[2] == 3 && s2[i].ts[3] == 0);
36
37 complex_t s3[n] = (complex_t[n])$lambda(int i) (complex_t){.t.y = .9, {.x = 42}};
38
39 $assert($forall (int i : 0 .. n-1) s3[i].x == 0 && s3[i].y == 0 &&
40 s3[i].t.x == 0 && s3[i].t.y == 0.9 &&
41 s3[i].u.x == 42);
42}
Note: See TracBrowser for help on using the repository browser.