D-Programming-Language/dmd — pull request #4067 by IgorStepanov (2014-10-14 22:39:32+00:00)
Title: [new AA] AA tests harmonization with new AA implementation

This PR harmonize tests for the new AA implementation with the old implementation. It is part of #3904
Diff is not very large.

`test/runnable/imports/link12144a.d`: New AA implemetation requires `bool opEquals(...) const` for key equality check. It is logical, AA shouldn't allow to change the key during AA work, thus AA should require const `opEquals` and `toHash`.

`test/runnable/sdtor.d`: This test is bit strange. I think, test shouldn't assert that compiler must skip postblit calls in some cases. Tests should declare cases when postblit must be called. Anywhere, template AA implemetation can't skip postblit calls for r-value args. See the [Issue 13492](https://issues.dlang.org/show_bug.cgi?id=13492).

`test/runnable/testaa.d` and `test/runnable/testaa2.d`:
This tests approves the wrong AA behaviour: postblit isn't called, when new key adding to AA.
```
struct Test
{
int* p;
this(int a)
{
p = new int;
*p = a;
}

this(this)
{
int a = *p;
p = new int;
*p = a;
}

~this()
{
*p = -1;
}

size_t toHash() const
{
return *p;
}

bool opEquals(const ref Test t) const
{
return *t.p == *p;
}

string toString() const
{
return to!string(*p);
}
}

void main()
{
int[Test] aa;
{
auto key = Test(42);
aa[key] = 1;
writeln(aa); //prints [42:1] as expected
}
writeln(aa); //prints [-1:1] because key is already destroyed
}
```
This tests is disabled now, because old AA implementation doesn't pass them, but new AA impementation does it.