We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a4f5e8f commit 44b2494Copy full SHA for 44b2494
test/runnable/foreach.d
@@ -12,8 +12,6 @@ a[2] = 23
12
a[] = 21
13
a[] = 22
14
a[] = 23
15
-a[foo] = 3
16
-a[bar] = 4
17
a = 63, b = 47, c = 83
18
a = 63, b = 48, c = 83
19
Success
@@ -230,16 +228,26 @@ void test7()
230
228
231
229
a["foo"] = 3;
232
a["bar"] = 4;
+ bool sawBar, sawFoo;
233
foreach (string s, uint v; a)
234
{
235
- printf("a[%.*s] = %d\n", cast(int)s.length, s.ptr, v);
236
if (s == "bar")
+ {
237
assert(v == 4);
+ assert(!sawBar);
238
+ sawBar = true;
239
+ }
240
else if (s == "foo")
241
242
assert(v == 3);
243
+ assert(!sawFoo);
244
+ sawFoo = true;
245
246
else
247
assert(0);
248
}
249
+ assert(sawBar);
250
+ assert(sawFoo);
251
252
253
0 commit comments