Mercurial > projects > dstress
changeset 1240:0972a593ff76
[Issue 596] New: Support array, arrayliteral and struct in switch and case
Nazo Humei <lovesyao@hotmail.com>
2006-11-25
news:bug-596-3@http.d.puremagic.com/issues/
author | thomask |
---|---|
date | Sat, 25 Nov 2006 17:53:20 +0000 |
parents | ee2da7e06729 |
children | 98f3c6ec25d8 |
files | run/c/case_05_A.d run/c/case_05_B.d run/c/case_05_C.d run/s/switch_23_A.d run/s/switch_23_B.d run/s/switch_23_C.d |
diffstat | 6 files changed, 174 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/c/case_05_A.d Sat Nov 25 17:53:20 2006 +0000 @@ -0,0 +1,35 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Nazo Humei <lovesyao@hotmail.com> +// @date@ 2006-11-25 +// @uri@ news:bug-596-3@http.d.puremagic.com/issues/ +// @desc@ [Issue 596] New: Support array, arrayliteral and struct in switch and case + +module dstress.run.c.case_05_A; + +int test(char[] s){ + switch(s){ + case ['a', '2']: + return 1; + case ['b']: + return 3; + default: + return 4; + } +} + +int main(){ + if(test("b") != 3){ + assert(0); + } + if(test("a2") != 1){ + assert(0); + } + if(test("abcd") != 4){ + assert(0); + } + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/c/case_05_B.d Sat Nov 25 17:53:20 2006 +0000 @@ -0,0 +1,35 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Nazo Humei <lovesyao@hotmail.com> +// @date@ 2006-11-25 +// @uri@ news:bug-596-3@http.d.puremagic.com/issues/ +// @desc@ [Issue 596] New: Support array, arrayliteral and struct in switch and case + +module dstress.run.c.case_05_B; + +int test(dchar[] s){ + switch(s){ + case [cast(dchar)'a', '2']: + return 1; + case [cast(dchar)'b']: + return 3; + default: + return 4; + } +} + +int main(){ + if(test("b") != 3){ + assert(0); + } + if(test("a2") != 1){ + assert(0); + } + if(test("abcd") != 4){ + assert(0); + } + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/c/case_05_C.d Sat Nov 25 17:53:20 2006 +0000 @@ -0,0 +1,35 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Nazo Humei <lovesyao@hotmail.com> +// @date@ 2006-11-25 +// @uri@ news:bug-596-3@http.d.puremagic.com/issues/ +// @desc@ [Issue 596] New: Support array, arrayliteral and struct in switch and case + +module dstress.run.c.case_05_C; + +int test(wchar[] s){ + switch(s){ + case [cast(wchar)'a', '2']: + return 1; + case [cast(wchar)'b']: + return 3; + default: + return 4; + } +} + +int main(){ + if(test("b") != 3){ + assert(0); + } + if(test("a2") != 1){ + assert(0); + } + if(test("abcd") != 4){ + assert(0); + } + + return 0; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/switch_23_A.d Sat Nov 25 17:53:20 2006 +0000 @@ -0,0 +1,23 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Nazo Humei <lovesyao@hotmail.com> +// @date@ 2006-11-25 +// @uri@ news:bug-596-3@http.d.puremagic.com/issues/ +// @desc@ [Issue 596] New: Support array, arrayliteral and struct in switch and case + +module dstress.run.s.switch_23_A; + +int main(){ + switch(['a']){ + case "c": + break; + case "a": + return 0; + case "b": + break; + } + + assert(0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/switch_23_B.d Sat Nov 25 17:53:20 2006 +0000 @@ -0,0 +1,23 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Nazo Humei <lovesyao@hotmail.com> +// @date@ 2006-11-25 +// @uri@ news:bug-596-3@http.d.puremagic.com/issues/ +// @desc@ [Issue 596] New: Support array, arrayliteral and struct in switch and case + +module dstress.run.s.switch_23_B; + +int main(){ + switch([cast(dchar)'a']){ + case "c"d: + break; + case "a"d: + return 0; + case "b"d: + break; + } + + assert(0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/switch_23_C.d Sat Nov 25 17:53:20 2006 +0000 @@ -0,0 +1,23 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Nazo Humei <lovesyao@hotmail.com> +// @date@ 2006-11-25 +// @uri@ news:bug-596-3@http.d.puremagic.com/issues/ +// @desc@ [Issue 596] New: Support array, arrayliteral and struct in switch and case + +module dstress.run.s.switch_23_C; + +int main(){ + switch([cast(wchar)'a']){ + case "c"w: + break; + case "a"w: + return 0; + case "b"w: + break; + } + + assert(0); +}