comparison tests/mini/funcs.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/funcs.d@d9d5d59873d8
children
comparison
equal deleted inserted replaced
340:351c0077d0b3 341:1bb99290e03a
1 extern(C) int printf(char*, ...);
2
3 void main()
4 {
5 printf("Testing functions\n");
6 int i = 5;
7 assert(a(i) == 110);
8 assert(i == 11);
9
10 S s;
11 s.i = 5;
12 d(s);
13 assert(s.i == 5);
14 e(s);
15 assert(s.i == 6);
16
17 printf(" SUCCESS\n");
18 }
19
20 int a(ref int i)
21 {
22 i*=2;
23 return b(i);
24 }
25
26 int b(ref int i)
27 {
28 i++;
29 return c(i);
30 }
31
32 int c(int i)
33 {
34 return i*10;
35 }
36
37 struct S
38 {
39 int i;
40 }
41
42 void d(S s)
43 {
44 s.i++;
45 }
46
47 void e(ref S s)
48 {
49 s.i++;
50 }