summary refs log tree commit diff stats
path: root/tests/collections
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-12-12 00:33:29 -0800
committerGitHub <noreply@github.com>2020-12-12 09:33:29 +0100
commitb1c232aca1baf7d9ccc6c7a86e9ac5a127bc2354 (patch)
tree8a14ca5b902e9811ea5a05fa76f29432fd033c3a /tests/collections
parent0b73106ccf983565d34654ee8b1167827b53b01a (diff)
downloadNim-b1c232aca1baf7d9ccc6c7a86e9ac5a127bc2354.tar.gz
improve tests for collections (#16328)
* improve tests for collections

* remove remaining code blocks in deques.nim

* improve runnableExamples
Diffstat (limited to 'tests/collections')
-rw-r--r--tests/collections/tcollections.nim69
1 files changed, 5 insertions, 64 deletions
diff --git a/tests/collections/tcollections.nim b/tests/collections/tcollections.nim
index 1e2858fb4..7677f7c1a 100644
--- a/tests/collections/tcollections.nim
+++ b/tests/collections/tcollections.nim
@@ -1,9 +1,10 @@
 discard """
-  output: ""
+  targets: "c js"
 """
 
-import sets, tables, deques, lists, critbits, sequtils
+# see also: tdeques, tlists, tcritbits
 
+import sets, tables, sequtils
 
 block tapply:
   var x = @[1, 2, 3]
@@ -12,19 +13,6 @@ block tapply:
   x.applyIt(it+5000)
   doAssert x == @[5111, 5112, 5113]
 
-
-block tdeques:
-  proc index(self: Deque[int], idx: Natural): int =
-    self[idx]
-
-  proc main =
-    var testDeque = initDeque[int]()
-    testDeque.addFirst(1)
-    assert testDeque.index(0) == 1
-
-  main()
-
-
 block tmapit:
   var x = @[1, 2, 3]
   # This mapIt call will run with preallocation because ``len`` is available.
@@ -75,6 +63,8 @@ doAssert $(toOrderedSet([1, 2, 3])) == "{1, 2, 3}"
 doAssert $(toOrderedSet(["1", "2", "3"])) == """{"1", "2", "3"}"""
 doAssert $(toOrderedSet(['1', '2', '3'])) == """{'1', '2', '3'}"""
 
+# see also: tcritbitsToString, tlistsToString
+
 # Tests for tables
 when defined(nimIntHash1):
   doAssert $({1: "1", 2: "2"}.toTable) == """{1: "1", 2: "2"}"""
@@ -83,55 +73,6 @@ else:
 let tabStr = $({"1": 1, "2": 2}.toTable)
 doAssert (tabStr == """{"2": 2, "1": 1}""" or tabStr == """{"1": 1, "2": 2}""")
 
-# Tests for deques
-block:
-  var d = initDeque[int]()
-  d.addLast(1)
-  doAssert $d == "[1]"
-block:
-  var d = initDeque[string]()
-  d.addLast("1")
-  doAssert $d == """["1"]"""
-block:
-  var d = initDeque[char]()
-  d.addLast('1')
-  doAssert $d == "['1']"
-
-# Tests for lists
-block:
-  var l = initDoublyLinkedList[int]()
-  l.append(1)
-  l.append(2)
-  l.append(3)
-  doAssert $l == "[1, 2, 3]"
-block:
-  var l = initDoublyLinkedList[string]()
-  l.append("1")
-  l.append("2")
-  l.append("3")
-  doAssert $l == """["1", "2", "3"]"""
-block:
-  var l = initDoublyLinkedList[char]()
-  l.append('1')
-  l.append('2')
-  l.append('3')
-  doAssert $l == """['1', '2', '3']"""
-
-# Tests for critbits
-block:
-  var t: CritBitTree[int]
-  t["a"] = 1
-  doAssert $t == """{"a": 1}"""
-block:
-  var t: CritBitTree[string]
-  t["a"] = "1"
-  doAssert $t == """{"a": "1"}"""
-block:
-  var t: CritBitTree[char]
-  t["a"] = '1'
-  doAssert $t == """{"a": '1'}"""
-
-
 # Test escaping behavior
 block:
   var s = ""