view run/b/bug_declaration_440_B.d @ 1535:20d8ee6523e1

updated to DMD-1.013
author thomask
date Mon, 07 May 2007 05:19:57 +0000
parents b8c0195059d9
children
line wrap: on
line source

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

// @author@	simon hudon <simon_member@pathlink.com>
// @date@	2006-07-17
// @uri@	http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D.bugs&artnum=7907
// @desc@	foreach on aggregate class in some delegate litterals

module dstress.run.b.bug_declaration_440_B;

int[] status;

class Container {
	int opApply (int delegate (ref int) dg) {
		int counter = 3;
		dg(counter);
		counter--;
		dg(counter);
		return 0;
	}
}

int main() {
	auto a = (
		delegate{
			foreach (i ; new Container()){
				status ~= i;
			}
		}
	);

	if(status.length != 0){
		assert(0);
	}

	a();

	if(status.length != 2){
		assert(0);
	}
	if((status[0] != 3) || (status[1] != 2)){
		assert(0);
	}

	return 0;
}