summary refs log tree commit diff stats
path: root/tests/collections
diff options
context:
space:
mode:
Diffstat (limited to 'tests/collections')
-rw-r--r--tests/collections/ttables.nim15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/collections/ttables.nim b/tests/collections/ttables.nim
index a2988e841..01dab44fc 100644
--- a/tests/collections/ttables.nim
+++ b/tests/collections/ttables.nim
@@ -235,6 +235,21 @@ block withKeyTest:
   except KeyError:
     discard
 
+block takeTest:
+  var t = initTable[string, int]()
+  t["key"] = 123
+
+  var val = 0
+  assert(t.take("key", val))
+  assert(val == 123)
+
+  val = -1
+  assert(not t.take("key", val))
+  assert(val == -1)
+
+  assert(not t.take("otherkey", val))
+  assert(val == -1)
+
 proc orderedTableSortTest() =
   var t = initOrderedTable[string, int](2)
   for key, val in items(data): t[key] = val