summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/thtmlparser2814.nim44
-rw-r--r--tests/stdlib/tos.nim92
-rw-r--r--tests/stdlib/tsplit.nim2
-rw-r--r--tests/stdlib/tunittest.nim6
4 files changed, 135 insertions, 9 deletions
diff --git a/tests/stdlib/thtmlparser2814.nim b/tests/stdlib/thtmlparser2814.nim
new file mode 100644
index 000000000..968d390f1
--- /dev/null
+++ b/tests/stdlib/thtmlparser2814.nim
@@ -0,0 +1,44 @@
+discard """
+  output: true
+"""
+import htmlparser
+import xmltree
+import strutils
+from streams import newStringStream
+
+
+## builds the two cases below and test that
+## ``//[dd,li]`` has "<p>that</p>" as children
+##
+##  <dl>
+##    <dt>this</dt>
+##    <dd>
+##      <p>that</p>
+##    </dd>
+##  </dl>
+
+##
+## <ul>
+##   <li>
+##     <p>that</p>
+##   </li>
+## </ul>
+
+
+for ltype in [["dl","dd"], ["ul","li"]]:
+  let desc_item = if ltype[0]=="dl": "<dt>this</dt>" else: ""
+  let item = "$1<$2><p>that</p></$2>" % [desc_item, ltype[1]]
+  let list = """ <$1>
+   $2
+</$1> """ % [ltype[0], item]
+
+  var errors : seq[string] = @[]
+
+  let parseH = parseHtml(newStringStream(list),"statichtml", errors =errors)
+
+  if $parseH.findAll(ltype[1])[0].child("p") != "<p>that</p>":
+    echo "case " & ltype[0] & " failed !"
+    quit(2)
+
+
+echo "true"
diff --git a/tests/stdlib/tos.nim b/tests/stdlib/tos.nim
index cae388792..1ddaacfcb 100644
--- a/tests/stdlib/tos.nim
+++ b/tests/stdlib/tos.nim
@@ -1,12 +1,88 @@
-# test some things of the os module
+discard """
+  output: '''true
+true
+true
+true
+true
+true
+true
+true
+true
+All:
+__really_obscure_dir_name/are.x
+__really_obscure_dir_name/created
+__really_obscure_dir_name/dirs
+__really_obscure_dir_name/files.q
+__really_obscure_dir_name/some
+__really_obscure_dir_name/test
+__really_obscure_dir_name/testing.r
+__really_obscure_dir_name/these.txt
+Files:
+__really_obscure_dir_name/are.x
+__really_obscure_dir_name/files.q
+__really_obscure_dir_name/testing.r
+__really_obscure_dir_name/these.txt
+Dirs:
+__really_obscure_dir_name/created
+__really_obscure_dir_name/dirs
+__really_obscure_dir_name/some
+__really_obscure_dir_name/test
+false
+false
+false
+false
+false
+false
+false
+false
+false
+'''
+"""
+# test os path creation, iteration, and deletion
 
 import os
 
-proc walkDirTree(root: string) =
-  for k, f in walkDir(root):
-    case k
-    of pcFile, pcLinkToFile: echo(f)
-    of pcDir: walkDirTree(f)
-    of pcLinkToDir: discard
+let files = @["these.txt", "are.x", "testing.r", "files.q"]
+let dirs = @["some", "created", "test", "dirs"]
 
-walkDirTree(".")
+let dname = "__really_obscure_dir_name"
+
+createDir(dname)
+echo dirExists(dname)
+
+# Test creating files and dirs
+for dir in dirs:
+  createDir(dname/dir)
+  echo dirExists(dname/dir)
+
+for file in files:
+  let fh = open(dname/file, fmReadWrite)
+  fh.close()
+  echo fileExists(dname/file)
+
+echo "All:"
+
+for path in walkPattern(dname/"*"):
+  echo path
+
+echo "Files:"
+
+for path in walkFiles(dname/"*"):
+  echo path
+
+echo "Dirs:"
+
+for path in walkDirs(dname/"*"):
+  echo path
+
+# Test removal of files dirs
+for dir in dirs:
+  removeDir(dname/dir)
+  echo dirExists(dname/dir)
+
+for file in files:
+  removeFile(dname/file)
+  echo fileExists(dname/file)
+
+removeDir(dname)
+echo dirExists(dname)
diff --git a/tests/stdlib/tsplit.nim b/tests/stdlib/tsplit.nim
index 5a1cd2f5f..44da58aca 100644
--- a/tests/stdlib/tsplit.nim
+++ b/tests/stdlib/tsplit.nim
@@ -9,7 +9,7 @@ for w in split("|abc|xy|z", {'|'}):
   s.add("#")
   s.add(w)
 
-if s == "#abc#xy#z":
+if s == "##abc#xy#z":
   echo "true"
 else:
   echo "false"
diff --git a/tests/stdlib/tunittest.nim b/tests/stdlib/tunittest.nim
index 73113ac68..e87cd3508 100644
--- a/tests/stdlib/tunittest.nim
+++ b/tests/stdlib/tunittest.nim
@@ -83,3 +83,9 @@ suite "suite with both":
 
   test "unittest with both 2":
     check c == 2
+
+suite "bug #4494":
+    test "Uniqueness check":
+      var tags = @[1, 2, 3, 4, 5]
+      check:
+        allIt(0..3, tags[it] != tags[it + 1])