Rune - Content-locking work 1/2
[rune.git] / tests / typedef.d
1 #!/usr/local/bin/rune -x
2 #
3 #       Demonstrate typedef
4
5 limport "sys";
6 import "stdio";
7
8 alias stdio.File *stdout = stdio.stdout;
9
10 class Fubar {
11         int a = 1;
12         int b = 2;
13         alias int c = a + b + 40 + b + a * 2 + a;
14         alias int d = c + c;
15 }
16
17 int
18 main(int ac, char **av)
19 {
20         Fubar f;
21         Fubar *g;
22         alias int x = f.d + f.d;
23         int y;
24
25         g.new();
26         stdout->show("Size should be 8:", sizeof(Fubar));
27         stdout->show("Size should be 8:", sizeof(*g));
28         y = x;
29         stdout->show("Y should be 192:", y);
30         y = f.d;
31         stdout->show("Y should be 86:", y);
32         y = f.d + f.c;
33         stdout->show("Y should be 129:", y);
34
35         stdout->show("Should be 1:", f.a);
36         stdout->show("Should be 2:", f.b);
37         stdout->show("Should be 48:", f.c);
38         stdout->show("Should be 96:", f.d);
39         stdout->show("Should be 192:", x);
40         stdout->show("Should be 1:", g->a);
41         stdout->show("Should be 2:", g->b);
42         stdout->show("Should be 48:", g->c);
43         stdout->show("Should be 96:", g->d);
44 }