source: CIVL/examples/arrayLambda/arrayLambdaCompoundLiterals.cvl

main
Last change on this file 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: 660 bytes
RevLine 
[1b85498]1$input int n;
2$assume(n > 0);
3
4typedef struct {
5 int x;
6 float y;
7} simple_t;
8
9int main() {
10 simple_t s[n] = (simple_t[n])$lambda(int j) (simple_t){42, .9};
11
12 $assert($forall (int i : 0 .. n-1) s[i].x == 42 && s[i].y == 0.9);
13
14 simple_t s2[n] = (simple_t[n])$lambda(int i) (simple_t){.y = .9, .x = 42};
15
16 $assert($forall (int i : 0 .. n-1) s2[i].x == 42 && s2[i].y == 0.9);
17
18 simple_t s3[n] = (simple_t[n])$lambda(int i) (simple_t){.y = .9};
19
20 $assert($forall (int i : 0 .. n-1) s3[i].x == 0 && s3[i].y == 0.9);
21
22 simple_t s4[n] = (simple_t[n])$lambda(int i) (simple_t){i};
23
24 $assert($forall (int i : 0 .. n-1) s4[i].x == i && s4[i].y == 0.0);
25}
Note: See TracBrowser for help on using the repository browser.