Skip to content

Commit

Permalink
Fix AA iteration order dependency in testaa2.d
Browse files Browse the repository at this point in the history
  • Loading branch information
n8sh committed Jul 2, 2020
1 parent feb042c commit 3d4eaed
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions test/runnable/testaa2.d
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ void foo2()
value = c.values;
assert(value.length == 2);

for (i = 0; i < key.length; i++)
// Make items always print in the same order despite the order of c.keys
// being unspecified so the test runner can validate the output.
foreach (isItTimeForB; 0 .. 2)
{
printf("c[\"%.*s\"] = %d\n", cast(int)key[i].length, key[i].ptr, value[i]);
for (i = 0; i < key.length; i++)
{
if ((key[i][0] == 'b') == isItTimeForB)
printf("c[\"%.*s\"] = %d\n", cast(int)key[i].length, key[i].ptr, value[i]);
}
}

assert("foo" in c);
Expand Down

0 comments on commit 3d4eaed

Please sign in to comment.