annotate tests/mini/union5.d @ 650:aa6a0b7968f7

Added test case for bug #100 Removed dubious check for not emitting static private global in other modules without access. This should be handled properly somewhere else, it's causing unresolved global errors for stuff that should work (in MiniD)
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 05 Oct 2008 17:28:15 +0200
parents 44f08170f4ef
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
1 module union5;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
2
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
3 union S
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
4 {
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
5 T t;
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
6 U u;
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
7 uint i;
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
8 struct {
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
9 ushort sl,sh;
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
10 }
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
11 }
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
12
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
13 struct T
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
14 {
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
15 int i;
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
16 }
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
17
443
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
18 struct U
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
19 {
44f08170f4ef Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 341
diff changeset
20 float f;
76
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
21 }
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
22
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
23 void main()
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
24 {
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
25 S s;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
26 assert(s.t.i == 0);
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
27 assert(s.u.f == 0);
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
28 s.t.i = -1;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
29 assert(s.i == 0xFFFF_FFFF);
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
30 float f = 3.1415;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
31 s.u.f = f;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
32 uint pi = *cast(uint*)&f;
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
33 assert(s.i == pi);
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
34 assert(s.sl == (pi&0xFFFF));
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
35 assert(s.sh == (pi>>>16));
9e1bd80a7e98 [svn r80] Fixed union literals
lindquist
parents:
diff changeset
36 }