Mercurial > projects > dstress
diff run/mini/arrays1.d @ 1628:c6ef09dfba4d
add mini test set from ldc project
author | Moritz Warning <moritzwarning@web.de> |
---|---|
date | Mon, 10 Jan 2011 19:47:18 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/mini/arrays1.d Mon Jan 10 19:47:18 2011 +0100 @@ -0,0 +1,43 @@ +module arrays1; + +extern(C) int printf(char*, ...); + +void integer() +{ + auto arr = new int[16]; + arr[1] = 42; + arr[6] = 555; + print_int(arr); + delete arr; +} + +void floating() +{ + auto arr = new float[6]; + arr[1] = 3.14159265; + arr[3] = 1.61803399; + print_float(arr); + delete arr; +} + +void print_int(int[] arr) +{ + printf("arr[%lu] = [", arr.length); + for (auto i=0; i<arr.length; i++) + printf("%d,", arr[i]); + printf("\b]\n"); +} + +void print_float(float[] arr) +{ + printf("arr[%lu] = [", arr.length); + for (auto i=0; i<arr.length; i++) + printf("%f,", arr[i]); + printf("\b]\n"); +} + +void main() +{ + integer(); + floating(); +}