summary refs log tree commit diff stats
path: root/tests/stdlib/torderedtable.nim
blob: 91a9169302c97b80a4a71212c9ce0da497791b81 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)