annotate tests/mini/aa6.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/aa6.d@d9d5d59873d8
children
rev   line source
lindquist@127 1 module aa6;
lindquist@127 2
lindquist@270 3 extern(C) int printf(char*, ...);
lindquist@270 4
lindquist@127 5 void main()
lindquist@127 6 {
lindquist@127 7 int[int] aa;
lindquist@127 8 aa = [1:1, 2:4, 3:9, 4:16];
lindquist@127 9 printf("---\n");
lindquist@127 10 foreach(int k, int v; aa)
lindquist@127 11 printf("aa[%d] = %d\n", k, v);
lindquist@127 12 aa.rehash;
lindquist@127 13 printf("---\n");
lindquist@127 14 foreach(int k, int v; aa)
lindquist@127 15 printf("aa[%d] = %d\n", k, v);
lindquist@127 16 size_t n = aa.length;
lindquist@127 17 assert(n == 4);
lindquist@127 18 int[] keys = aa.keys;
lindquist@127 19 assert(keys[] == [1,2,3,4][]);
lindquist@127 20 int[] vals = aa.values;
lindquist@127 21 assert(vals[] == [1,4,9,16][]);
lindquist@127 22 aa.remove(3);
lindquist@127 23 printf("---\n");
lindquist@127 24 foreach(int k, int v; aa)
lindquist@127 25 printf("aa[%d] = %d\n", k, v);
lindquist@127 26 assert(aa.length == 3);
lindquist@127 27 }