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