annotate tests/mini/aa3.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/aa3.d@d9d5d59873d8
children
rev   line source
lindquist@109 1 module aa3;
lindquist@109 2
lindquist@270 3 extern(C) int printf(char*, ...);
lindquist@270 4 alias char[] string;
lindquist@270 5
lindquist@109 6 void main()
lindquist@109 7 {
lindquist@109 8 int[string] aa;
lindquist@109 9 {aa["hello"] = 1;}
lindquist@109 10 {int* p = "" in aa;}
lindquist@109 11 aa[" worl"] = 2;
lindquist@109 12 aa["d"] = 3;
lindquist@109 13 aa["thisisgreat"] = 10;
lindquist@109 14 int sum;
lindquist@109 15 string cat;
lindquist@109 16 {
lindquist@109 17 foreach(k,v;aa)
lindquist@109 18 {
lindquist@109 19 printf("int[%.*s] = %d\n", k.length, k.ptr, v);
lindquist@109 20 sum += v;
lindquist@109 21 cat ~= k;
lindquist@109 22 }
lindquist@109 23 }
lindquist@109 24 assert(sum == 16);
lindquist@109 25 printf("cat = %.*s\n", cat.length, cat.ptr);
lindquist@109 26 assert(cat.length == 22);
lindquist@109 27 }