view run/a/associative_array_19_O.d @ 1630:d0efa3ae5522 default tip

run/mini/naked_asm5: New x86_64 ABI passes the arguments in reverse order.
author David Nadlinger <code@klickverbot.at>
date Sat, 23 Apr 2011 22:57:32 +0200
parents b8c0195059d9
children
line wrap: on
line source

// $HeadURL$
// $Date$
// $Author$

// @author@	Sebastian Beschke <s.beschke@gmx.de>
// @date@	2005-03-25
// @uri@	http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.bugs&artnum=6821

// @WARNING@ direct access to Phobos' GC

module dstress.run.a.associative_array_19_O;

import std.gc;

union Key{
	char x;
	ubyte[4] y;
}

class Payload {
	this(Key value) {
		value.x += 1;
		this.value = 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);
	}

	for(size_t step = 0; step < 10000; step++){
		foreach(Key key; allKeys) {
			if(!(key in aa)){
				assert(0);
			}
			Payload p = aa[key];
			if(p.value.x != key.x + 1){
				assert(0);
			}
		}
		std.gc.fullCollect();
	}

	return 0;
}