summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-05-06 11:53:22 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-05-06 11:53:22 +0200
commita3e0a7ebbb7682fa40643b1e876ff229e76ba740 (patch)
treea1084976e758c4aea4263b124e0dd563a54b362b /tests
parentc22e0d414ddff0404a0adb1a8fc18d867e49ecd9 (diff)
parent78315792d33a26e519278aec650f76022f53082b (diff)
downloadNim-a3e0a7ebbb7682fa40643b1e876ff229e76ba740.tar.gz
Merge branch 'devel' of github.com:nim-lang/Nim into devel
Diffstat (limited to 'tests')
-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