Mercurial > projects > ldc
comparison test/aa6.d @ 127:facc562f5674 trunk
[svn r131] Fixed #11
All associative array properties now work as they should.
Fixed problems with some cases of array.length and array.ptr.
Fixed some problems with array properties.
Fixed 'in' contracts.
author | lindquist |
---|---|
date | Fri, 30 Nov 2007 12:56:52 +0100 |
parents | |
children | d9d5d59873d8 |
comparison
equal
deleted
inserted
replaced
126:a2c2c3c1a73d | 127:facc562f5674 |
---|---|
1 module aa6; | |
2 | |
3 void main() | |
4 { | |
5 int[int] aa; | |
6 aa = [1:1, 2:4, 3:9, 4:16]; | |
7 printf("---\n"); | |
8 foreach(int k, int v; aa) | |
9 printf("aa[%d] = %d\n", k, v); | |
10 aa.rehash; | |
11 printf("---\n"); | |
12 foreach(int k, int v; aa) | |
13 printf("aa[%d] = %d\n", k, v); | |
14 size_t n = aa.length; | |
15 assert(n == 4); | |
16 int[] keys = aa.keys; | |
17 assert(keys[] == [1,2,3,4][]); | |
18 int[] vals = aa.values; | |
19 assert(vals[] == [1,4,9,16][]); | |
20 aa.remove(3); | |
21 printf("---\n"); | |
22 foreach(int k, int v; aa) | |
23 printf("aa[%d] = %d\n", k, v); | |
24 assert(aa.length == 3); | |
25 } |