diff options
Diffstat (limited to 'gcc/testsuite/gdc.test/runnable/foreach.d')
-rw-r--r-- | gcc/testsuite/gdc.test/runnable/foreach.d | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/gcc/testsuite/gdc.test/runnable/foreach.d b/gcc/testsuite/gdc.test/runnable/foreach.d index 331c927504a..f0d1ea9ba9c 100644 --- a/gcc/testsuite/gdc.test/runnable/foreach.d +++ b/gcc/testsuite/gdc.test/runnable/foreach.d @@ -1,3 +1,22 @@ +/* +RUN_OUTPUT: +--- +u = 17 +u = 1 +u = 1 +u = 1 +u = 1 +a[0] = 21 +a[1] = 22 +a[2] = 23 +a[] = 21 +a[] = 22 +a[] = 23 +a = 63, b = 47, c = 83 +a = 63, b = 48, c = 83 +Success +--- +*/ import core.stdc.stdio; @@ -209,16 +228,26 @@ void test7() a["foo"] = 3; a["bar"] = 4; + bool sawBar, sawFoo; foreach (string s, uint v; a) { - printf("a[%.*s] = %d\n", s.length, s.ptr, v); if (s == "bar") + { assert(v == 4); + assert(!sawBar); + sawBar = true; + } else if (s == "foo") + { assert(v == 3); + assert(!sawFoo); + sawFoo = true; + } else assert(0); } + assert(sawBar); + assert(sawFoo); } |