Mercurial > projects > ldc
comparison tests/mini/aaequality.d @ 1512:09734fb929c0
Make == for associative arrays test for equality, not identity.
_aaEq was added to runtime/internal/aaA.d which forwards to
TypeInfo_AssociativeArray.equals in genobj.d. On the codegen side, DtoAAEquals
was added to gen/aa.cpp and is called from EqualExp::toElem in gen/toir.cpp.
I assume that the frontend will produce an error if == is used on associative
arrays of different type.
This fixes DMD bug 1429.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 21 Jun 2009 19:05:24 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1511:5b66008246bb | 1512:09734fb929c0 |
---|---|
1 void test(K,V)(K k1, V v1, K k2, V v2, K k3, V v3) | |
2 { | |
3 V[K] a, b; | |
4 a[k1] = v1; | |
5 a[k2] = v2; | |
6 assert(a != b); | |
7 assert(b != a); | |
8 assert(a == a); | |
9 assert(b == b); | |
10 | |
11 b[k1] = v1; | |
12 assert(a != b); | |
13 assert(b != a); | |
14 | |
15 b[k2] = v2; | |
16 assert(a == b); | |
17 assert(b == a); | |
18 | |
19 b[k1] = v2; | |
20 assert(a != b); | |
21 assert(b != a); | |
22 | |
23 b[k1] = v1; | |
24 b[k2] = v3; | |
25 assert(a != b); | |
26 assert(b != a); | |
27 | |
28 b[k2] = v2; | |
29 b[k3] = v3; | |
30 assert(a != b); | |
31 assert(b != a); | |
32 } | |
33 | |
34 void main() | |
35 { | |
36 test!(int,int)(1, 2, 3, 4, 5, 6); | |
37 test!(char[],int)("abc", 2, "def", 4, "geh", 6); | |
38 test!(int,char[])(1, "abc", 2, "def", 3, "geh"); | |
39 test!(char[],char[])("123", "abc", "456", "def", "789", "geh"); | |
40 | |
41 Object a = new Object, b = new Object, c = new Object; | |
42 test!(Object, Object)(a, a, b, b, c, c); | |
43 | |
44 int[int] a2 = [1:2, 2:3, 3:4]; | |
45 int[int] b2 = [1:2, 2:5, 3:4]; | |
46 int[int] c2 = [1:2, 2:3]; | |
47 test!(int,int[int])(1,a2, 2,b2, 3,c2); | |
48 } |