933
|
1 // $HeadURL$
|
|
2 // $Date$
|
1090
|
3 // $Author$
|
933
|
4
|
|
5 // @author@ Sebastian Beschke <s.beschke@gmx.de>
|
|
6 // @date@ 2005-03-25
|
1489
|
7 // @uri@ http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.bugs&artnum=6821
|
933
|
8
|
|
9 // @WARNING@ direct access to Phobos' GC
|
|
10
|
|
11 module dstress.run.a.associative_array_19_V;
|
|
12
|
|
13 import std.gc;
|
|
14
|
|
15 union Key{
|
|
16 char x;
|
|
17 }
|
|
18
|
|
19 class Payload {
|
|
20 this(Key value) {
|
|
21 value.x += 1;
|
|
22 this.value = value;
|
|
23 }
|
1089
|
24
|
933
|
25 Key value;
|
|
26
|
|
27 ubyte[3] dummy;
|
|
28 }
|
|
29
|
|
30 int main(){
|
|
31 Payload[Key] aa;
|
|
32
|
|
33 Key[] allKeys;
|
|
34 static Key a = { 'a' };
|
|
35 static Key b = { 'b' };
|
|
36 static Key c = { 'c' };
|
|
37 allKeys ~= a;
|
|
38 allKeys ~= b;
|
|
39 allKeys ~= c;
|
|
40
|
|
41 foreach(Key key; allKeys) {
|
|
42 aa[key] = new Payload(key);
|
|
43 }
|
1089
|
44
|
933
|
45 for(size_t step = 0; step < 10000; step++){
|
|
46 foreach(Key key; allKeys) {
|
|
47 if(!(key in aa)){
|
|
48 assert(0);
|
|
49 }
|
|
50 Payload p = aa[key];
|
|
51 if(p.value.x != key.x + 1){
|
|
52 assert(0);
|
|
53 }
|
|
54 }
|
|
55 std.gc.fullCollect();
|
|
56 }
|
|
57
|
|
58 return 0;
|
|
59 }
|
|
60
|