annotate 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
rev   line source
lindquist@88 1 module union7;
lindquist@88 2
lindquist@88 3 pragma(LLVM_internal, "notypeinfo")
lindquist@88 4 struct Union
lindquist@88 5 {
lindquist@88 6 union {
lindquist@88 7 double g;
lindquist@88 8 struct {
lindquist@88 9 short s1,s2,s3,s4;
lindquist@88 10 }
lindquist@88 11 }
lindquist@88 12 union {
lindquist@88 13 float f;
lindquist@88 14 long l;
lindquist@88 15 }
lindquist@88 16 }
lindquist@88 17
lindquist@88 18 Union a = { f:4f };
lindquist@88 19 Union b = { 3.0, f:2 };
lindquist@88 20 Union c = { l:42, g:2.0 };
lindquist@88 21 Union d = { s2:3 };
lindquist@88 22 Union e = { s1:3, s4:4, l:5 };
lindquist@88 23
lindquist@88 24 void main()
lindquist@88 25 {
lindquist@88 26 assert(a.f == 4f);
lindquist@88 27 assert(a.g !<>= 0.0);
lindquist@88 28 assert((a.l>>>32) == 0);
lindquist@88 29
lindquist@88 30 assert(b.g == 3.0);
lindquist@88 31 assert(b.f == 2f);
lindquist@88 32
lindquist@88 33 assert(c.l == 42);
lindquist@88 34 assert(c.g == 2.0);
lindquist@88 35
lindquist@88 36 assert(d.s1 == 0);
lindquist@88 37 assert(d.s2 == 3);
lindquist@88 38 assert(d.s3 == 0);
lindquist@88 39 assert(d.s4 == 0);
lindquist@88 40 {assert(d.f !<>= 0f);}
lindquist@88 41 {}
lindquist@88 42 assert(e.s1 == 3);
lindquist@88 43 assert(e.s2 == 0);
lindquist@88 44 assert(e.s3 == 0);
lindquist@88 45 {assert(e.s4 == 4);}
lindquist@88 46 {}
lindquist@88 47 assert(e.l == 5);
lindquist@88 48 }