Mercurial > projects > ldc
diff tests/mini/calls1.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/calls1.d@068cb3c60afb |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/mini/calls1.d Sun Jul 13 02:51:19 2008 +0200 @@ -0,0 +1,66 @@ +module calls1; +import tango.core.Vararg; +extern(C) int printf(char*, ...); +void main() +{ + {int a = byVal1(3);} + {int a = void; byRef1(a);} + {char[] c = void; refType(c);} + {char[] c = void; refTypeByRef(c);} + {S s = void; structByVal(s);} + {S s = void; structByRef(s);} + {S s = void; structByPtr(&s);} + {printf("c-varargs %d %d %d\n", 1,2,3);} + {int i=3; float f=24.7; dvararg(i,f);} + {char[] s = "hello"; dvarargRefTy(s);} + {char[] ss = "hello world!"; dvarargRefTy(ss);} +} + +int byVal1(int a) +{ + return a; +} + +void byRef1(ref int a) +{ + a = 3; +} + +void refType(char[] s) +{ +} + +void refTypeByRef(ref char[] s) +{ +} + +struct S +{ + float f; + double d; + long l; + byte b; +} + +void structByVal(S s) +{ +} + +void structByRef(ref S s) +{ +} + +void structByPtr(S* s) +{ +} + +void dvararg(...) +{ + printf("%d %.1f\n", va_arg!(int)(_argptr), va_arg!(float)(_argptr)); +} + +void dvarargRefTy(...) +{ + char[] s = va_arg!(char[])(_argptr); + printf("%.*s\n", s.length, s.ptr); +}