comparison tests/minicomplex/vararg2.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
children
comparison
equal deleted inserted replaced
340:351c0077d0b3 341:1bb99290e03a
1 module tangotests.vararg2;
2
3 extern(C) int printf(char*, ...);
4
5 import tango.core.Vararg;
6
7 void main()
8 {
9 func(0xf00, 1, " ", 2, " ", 3, "\n", 0.3, "\n");
10 }
11
12 void func(int foo, ...)
13 {
14 foreach(t; _arguments)
15 {
16 if (t == typeid(char[]))
17 {
18 char[] str = va_arg!(char[])(_argptr);
19 printf("%.*s", str.length, str.ptr);
20 }
21 else if (t == typeid(int))
22 {
23 printf("%d", va_arg!(int)(_argptr));
24 }
25 else if (t == typeid(float))
26 {
27 printf("%f", va_arg!(float)(_argptr));
28 }
29 else if (t == typeid(double))
30 {
31 printf("%f", va_arg!(double)(_argptr));
32 }
33 else if (t == typeid(real))
34 {
35 printf("%f", va_arg!(real)(_argptr));
36 }
37 else
38 {
39 assert(0, "not int");
40 }
41 }
42 }