From 2baeafd7b275975c6519846720fbe09edc4f103a Mon Sep 17 00:00:00 2001 From: Nathan Sashihara <21227491+n8sh@users.noreply.github.com> Date: Wed, 8 Jul 2020 09:46:37 -0700 Subject: [PATCH] Fix AA iteration order dependency in test/runnable/foreach.d --- test/runnable/foreach.d | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/runnable/foreach.d b/test/runnable/foreach.d index dd27ea85f2f6..f0d1ea9ba9cd 100644 --- a/test/runnable/foreach.d +++ b/test/runnable/foreach.d @@ -12,8 +12,6 @@ a[2] = 23 a[] = 21 a[] = 22 a[] = 23 -a[foo] = 3 -a[bar] = 4 a = 63, b = 47, c = 83 a = 63, b = 48, c = 83 Success @@ -230,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", cast(int)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); }