view tests/mini/aaequality.d @ 1605:1d5721f9ae18

[WIP] Merge DMD r251: bugzilla 111 (appending a dchar to a char[]) This patch needs some work in the code generation, because of the runtime changes (functions "_d_arrayappendcd" and "_d_arrayappendwd" are added). This doesn't affect existing code though, it just makes with patch a little useless, because something like this: char [] s; s ~= '\u6211'; That failed to compile with a nice error message previously to this change, now fails with and ugly error message (a failed assertion). Apparently there is a regression introduced by this patch too, when compiling Dil I get this assertion message: ldc: /home/luca/tesis/ldc/gen/statements.cpp:132: virtual void ReturnStatement::toIR(IRState*): Assertion `p->topfunc()->getReturnType() == llvm::Type::getVoidTy(gIR->context())' failed. 0 ldc 0x08a91628 Thank god we have bisecting capabilities in VCSs now ;) --- dmd/expression.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 41 insertions(+), 6 deletions(-)
author Leandro Lucarella <llucax@gmail.com>
date Wed, 06 Jan 2010 15:18:19 -0300
parents 09734fb929c0
children
line wrap: on
line source

void test(K,V)(K k1, V v1, K k2, V v2, K k3, V v3)
{
    V[K] a, b;
    a[k1] = v1;
    a[k2] = v2;
    assert(a != b);
    assert(b != a);
    assert(a == a);
    assert(b == b);
    
    b[k1] = v1;
    assert(a != b);
    assert(b != a);

    b[k2] = v2;
    assert(a == b);
    assert(b == a);
    
    b[k1] = v2;
    assert(a != b);
    assert(b != a);
    
    b[k1] = v1;
    b[k2] = v3;
    assert(a != b);
    assert(b != a);
    
    b[k2] = v2;
    b[k3] = v3;
    assert(a != b);
    assert(b != a);
}

void main()
{
    test!(int,int)(1, 2, 3, 4, 5, 6);
    test!(char[],int)("abc", 2, "def", 4, "geh", 6);
    test!(int,char[])(1, "abc", 2, "def", 3, "geh");
    test!(char[],char[])("123", "abc", "456", "def", "789", "geh");
    
    Object a = new Object, b = new Object, c = new Object;
    test!(Object, Object)(a, a, b, b, c, c);
    
    int[int] a2 = [1:2, 2:3, 3:4];
    int[int] b2 = [1:2, 2:5, 3:4];
    int[int] c2 = [1:2, 2:3];
    test!(int,int[int])(1,a2, 2,b2, 3,c2);
}