Mercurial > projects > dstress
changeset 1137:679105b449a6
foreach on aggregate class in some delegate litterals
simon hudon <simon_member@pathlink.com>
2006-07-17
news:e9f3bk$21hp$1@digitaldaemon.com
author | thomask |
---|---|
date | Thu, 14 Sep 2006 07:15:59 +0000 |
parents | 6d49ea394165 |
children | cb3296d36dce |
files | run/b/bug_declaration_440_A.d run/b/bug_declaration_440_B.d run/b/bug_declaration_440_C.d |
diffstat | 3 files changed, 141 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/b/bug_declaration_440_A.d Thu Sep 14 07:15:59 2006 +0000 @@ -0,0 +1,47 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ simon hudon <simon_member@pathlink.com> +// @date@ 2006-07-17 +// @uri@ news:e9f3bk$21hp$1@digitaldaemon.com +// @desc@ foreach on aggregate class in some delegate litterals + +module dstress.run.b.bug_declaration_440_A; + +int[] status; + +class Container { + int opApply (int delegate (inout int) dg) { + int counter = 3; + dg(counter); + counter--; + dg(counter); + return 0; + } +} + +int main() { + auto a = ( + { + 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; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/b/bug_declaration_440_B.d Thu Sep 14 07:15:59 2006 +0000 @@ -0,0 +1,47 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ simon hudon <simon_member@pathlink.com> +// @date@ 2006-07-17 +// @uri@ news:e9f3bk$21hp$1@digitaldaemon.com +// @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 (inout 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; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/b/bug_declaration_440_C.d Thu Sep 14 07:15:59 2006 +0000 @@ -0,0 +1,47 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ simon hudon <simon_member@pathlink.com> +// @date@ 2006-07-17 +// @uri@ news:e9f3bk$21hp$1@digitaldaemon.com +// @desc@ foreach on aggregate class in some delegate litterals + +module dstress.run.b.bug_declaration_440_C; + +int[] status; + +class Container { + int opApply (int delegate (inout 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; +}