1 // EXTRA_SOURCES: imports/tlsa.d
2
3 import core.stdc.stdio;
4 import imports.tlsa;
5
6 int x = 3;
7
bar()8 void bar()
9 {
10 int* px = &x;
11 assert(x == 3);
12 x++;
13 printf("x = %d\n", x);
14 px = &x;
15 printf("px = %p\n", px);
16 assert(*px == 4);
17 (*px)++;
18 assert(x == 5);
19 }
20
21
test1()22 void test1()
23 {
24 bar();
25 printf("%d\n", x);
26 printf("%d\n", foo!()());
27 }
28
29 /************************************/
30
31 long fooa;
32 long foob;
33 int bara = 0x12345678;
34 int barb = 0x9ABCDEFF;
35
test2()36 void test2()
37 {
38 fooa++;
39 foob--;
40 bara++;
41 barb++;
42 printf("%lld %lld %x %x\n", fooa, foob, bara, barb);
43 assert(fooa == 1);
44 assert(foob == -1);
45 assert(bara == 0x12345679);
46 assert(barb == 0x9ABCDF00);
47 }
48
49 /************************************/
50
abc3(T)51 int abc3(T)(T t)
52 {
53 static T qqq;
54 static T rrr;
55 static T sss = 8;
56 static T ttt = 9;
57 printf("qqq = %d, rrr = %d, sss = %d, ttt = %d\n", qqq, rrr, sss, ttt);
58 assert(sss == 8);
59 assert(ttt == 9);
60 rrr += 7;
61 return t + ++qqq + rrr;
62 }
63
test3()64 void test3()
65 {
66 auto i = abc3(3);
67 printf("i = x%x\n", i);
68 assert(i == 11);
69 i = abc3(4);
70 printf("i = x%x\n", i);
71 assert(i == 20);
72 }
73
74 /************************************/
75
test4()76 void test4()
77 {
78
79 auto i = bar4();
80 printf("i = x%x\n", i);
81 assert(i == 0x23);
82 i = abc4(4);
83 printf("i = x%x\n", i);
84 assert(i == 0x31);
85 }
86
87 /************************************/
88
main()89 int main()
90 {
91 test1();
92 test2();
93 test3();
94 test4();
95
96 printf("Success\n");
97 return 0;
98 }
99
100