Mercurial > projects > ldc
comparison tests/mini/union7.d @ 341:1bb99290e03a trunk
[svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
author | lindquist |
---|---|
date | Sun, 13 Jul 2008 02:51:19 +0200 |
parents | test/union7.d@058d3925950e |
children | 44f08170f4ef |
comparison
equal
deleted
inserted
replaced
340:351c0077d0b3 | 341:1bb99290e03a |
---|---|
1 module union7; | |
2 | |
3 pragma(LLVM_internal, "notypeinfo") | |
4 struct Union | |
5 { | |
6 union { | |
7 double g; | |
8 struct { | |
9 short s1,s2,s3,s4; | |
10 } | |
11 } | |
12 union { | |
13 float f; | |
14 long l; | |
15 } | |
16 } | |
17 | |
18 Union a = { f:4f }; | |
19 Union b = { 3.0, f:2 }; | |
20 Union c = { l:42, g:2.0 }; | |
21 Union d = { s2:3 }; | |
22 Union e = { s1:3, s4:4, l:5 }; | |
23 | |
24 void main() | |
25 { | |
26 assert(a.f == 4f); | |
27 assert(a.g !<>= 0.0); | |
28 assert((a.l>>>32) == 0); | |
29 | |
30 assert(b.g == 3.0); | |
31 assert(b.f == 2f); | |
32 | |
33 assert(c.l == 42); | |
34 assert(c.g == 2.0); | |
35 | |
36 assert(d.s1 == 0); | |
37 assert(d.s2 == 3); | |
38 assert(d.s3 == 0); | |
39 assert(d.s4 == 0); | |
40 {assert(d.f !<>= 0f);} | |
41 {} | |
42 assert(e.s1 == 3); | |
43 assert(e.s2 == 0); | |
44 assert(e.s3 == 0); | |
45 {assert(e.s4 == 4);} | |
46 {} | |
47 assert(e.l == 5); | |
48 } |