Files
ldc/tests/mini/aa7.d
Tomas Lindquist Olsen 9d7f16b967 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Reimplemented support for nested functions/class using a new approach.
Added error on taking address of intrinsic.
Fixed problems with the ->syntaxCopy of TypeFunction delegate exp.
Removed DtoDType and replaced all uses with ->toBasetype() instead.
Removed unused inplace stuff.
Fixed a bunch of issues in the runtime unittests, not complete yet.
Added mini tests.
2008-08-10 08:37:38 +02:00

58 lines
879 B
D

// adapted from dstress.run.a.associative_array_19_A to catch regressions early
module mini.aa7;
extern (C) int printf(char*, ...);
extern (C) void gc_collect();
union Key{
char x;
}
class Payload {
this(Key value) {
value.x += 1;
_value = value;
}
Key value() {
return _value;
}
Key _value;
}
int main(){
Payload[Key] aa;
Key[] allKeys;
static Key a = { 'a' };
static Key b = { 'b' };
static Key c = { 'c' };
allKeys ~= a;
allKeys ~= b;
allKeys ~= c;
foreach(Key key; allKeys) {
aa[key] = new Payload(key);
}
int i = 0;
foreach(Key key; allKeys) {
printf("1st #%d\n", i++);
assert(key in aa);
}
gc_collect();
i = 0;
foreach(Key key; allKeys) {
printf("2nd #%d\n", i++);
assert(key in aa);
}
return 0;
}