summary refs log tree commit diff stats
path: root/tests/stdlib/torderedtable.nim
diff options
context:
space:
mode:
authorParashurama <Rhagdamaziel@ymail.com>2017-06-05 13:16:30 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-06-05 13:16:30 +0200
commitcd51628f577d35f8ba8b9a40162c7b74d1e71439 (patch)
treed146e8e8acb7f507870f00d8f247a563031562c8 /tests/stdlib/torderedtable.nim
parent55c244400d303d5a7c30cc234cb062603f02c2ae (diff)
downloadNim-cd51628f577d35f8ba8b9a40162c7b74d1e71439.tar.gz
fix orderedtable enlarge proc. (#5937)
This fixes issue #5917
Diffstat (limited to 'tests/stdlib/torderedtable.nim')
-rw-r--r--tests/stdlib/torderedtable.nim18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/stdlib/torderedtable.nim b/tests/stdlib/torderedtable.nim
new file mode 100644
index 000000000..91a916930
--- /dev/null
+++ b/tests/stdlib/torderedtable.nim
@@ -0,0 +1,18 @@
+import tables, random
+var t = initOrderedTable[int,string]()
+
+# this tests issue #5917
+var data = newSeq[int]()
+for i in 0..<1000:
+  var x = random(1000)
+  if x notin t: data.add(x)
+  t[x] = "meh"
+
+# this checks that keys are re-inserted
+# in order when table is enlarged.
+var i = 0
+for k, v in t:
+  doAssert(k == data[i])
+  doAssert(v == "meh")
+  inc(i)
+