Rune - Fix array passing, optimize constant array indices
[rune.git] / tests / typedef.d
1 #!/usr/local/bin/rune -x
2 #
3 #       Demonstrate typedef
4
5 import "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         f.a = 3;
31         stdout->show("x should be 224:", x);
32         y = f.d;
33         stdout->show("y should be 112:", y);
34         y = f.d + f.c;
35         stdout->show("y should be 168:", y);
36         f.a = 1;
37
38         stdout->show("Should be 1:", f.a);
39         stdout->show("Should be 2:", f.b);
40         stdout->show("Should be 48:", f.c);
41         stdout->show("Should be 96:", f.d);
42         stdout->show("Should be 192:", x);
43         stdout->show("Should be 1:", g->a);
44         stdout->show("Should be 2:", g->b);
45         stdout->show("Should be 48:", g->c);
46         stdout->show("Should be 96:", g->d);
47 }