Skip to content

Commit 44b2494

Browse files
n8shMoonlightSentinel
authored andcommitted
Fix AA iteration order dependency in test/runnable/foreach.d
1 parent a4f5e8f commit 44b2494

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/runnable/foreach.d

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ a[2] = 23
1212
a[] = 21
1313
a[] = 22
1414
a[] = 23
15-
a[foo] = 3
16-
a[bar] = 4
1715
a = 63, b = 47, c = 83
1816
a = 63, b = 48, c = 83
1917
Success
@@ -230,16 +228,26 @@ void test7()
230228

231229
a["foo"] = 3;
232230
a["bar"] = 4;
231+
bool sawBar, sawFoo;
233232
foreach (string s, uint v; a)
234233
{
235-
printf("a[%.*s] = %d\n", cast(int)s.length, s.ptr, v);
236234
if (s == "bar")
235+
{
237236
assert(v == 4);
237+
assert(!sawBar);
238+
sawBar = true;
239+
}
238240
else if (s == "foo")
241+
{
239242
assert(v == 3);
243+
assert(!sawFoo);
244+
sawFoo = true;
245+
}
240246
else
241247
assert(0);
242248
}
249+
assert(sawBar);
250+
assert(sawFoo);
243251
}
244252

245253

0 commit comments

Comments
 (0)