comparison tests/mini/aa7.d @ 486:a34078905d01

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.
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 10 Aug 2008 08:37:38 +0200
parents
children f8c979770af3
comparison
equal deleted inserted replaced
485:50f6e2337a6b 486:a34078905d01
1 // adapted from dstress.run.a.associative_array_19_A to catch regressions early
2
3 module mini.aa7;
4
5 extern (C) int printf(char*, ...);
6
7 extern (C) void gc_collect();
8
9 union Key{
10 char x;
11 }
12
13 class Payload {
14 this(Key value) {
15 value.x += 1;
16 _value = value;
17 }
18
19 Key value() {
20 return _value;
21 }
22
23 Key _value;
24 }
25
26 int main(){
27 Payload[Key] aa;
28
29 Key[] allKeys;
30 static Key a = { 'a' };
31 static Key b = { 'b' };
32 static Key c = { 'c' };
33 allKeys ~= a;
34 allKeys ~= b;
35 allKeys ~= c;
36
37 foreach(Key key; allKeys) {
38 aa[key] = new Payload(key);
39 }
40
41 int i = 0;
42 foreach(Key key; allKeys) {
43 printf("1st #%d\n", i++);
44 assert(key in aa);
45 }
46
47 gc_collect();
48
49 i = 0;
50 foreach(Key key; allKeys) {
51 printf("2nd #%d\n", i++);
52 assert(key in aa);
53 }
54
55 return 0;
56 }
57