summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2018-11-15 01:57:02 +0100
committerAraq <rumpf_a@web.de>2018-11-23 11:58:28 +0100
commit9c2365d5c2229f327d19262894995047a357e252 (patch)
treeac6d99d9e65afe900d36095b266212fcd262d18b /tests
parente012eb100109d343b7cdbe2598d439d84eda7830 (diff)
downloadNim-9c2365d5c2229f327d19262894995047a357e252.tar.gz
activated more tests, allow input in test spec
Diffstat (limited to 'tests')
-rw-r--r--tests/cpp/tnativesockets.nim1
-rw-r--r--tests/dll/server.nim8
-rw-r--r--tests/init/tuninit1.nim3
-rw-r--r--tests/macros/tmemit.nim6
-rw-r--r--tests/objects/tobjects.nim9
-rw-r--r--tests/osproc/ta_out.nim11
-rw-r--r--tests/osproc/tafalse.nim4
-rw-r--r--tests/osproc/texitcode.nim1
-rw-r--r--tests/stdlib/tmath2.nim85
-rw-r--r--tests/stdlib/tmemfiles1.nim3
-rw-r--r--tests/stdlib/tmemlines.nim4
-rw-r--r--tests/stdlib/tmemslices.nim6
-rw-r--r--tests/stdlib/tnet.nim4
-rw-r--r--tests/stdlib/tosprocterminate.nim4
-rw-r--r--tests/stdlib/tposix.nim5
-rw-r--r--tests/stdlib/tquit.nim6
-rw-r--r--tests/stdlib/trepr2.nim5
-rw-r--r--tests/stdlib/trstgen.nim12
-rw-r--r--tests/stdlib/tsortcall.nim6
-rw-r--r--tests/stdlib/tstreams.nim16
-rw-r--r--tests/stdlib/tstrtabs.nim91
-rw-r--r--tests/stdlib/twalker.nim13
-rw-r--r--tests/template/ttempl3.nim6
23 files changed, 186 insertions, 123 deletions
diff --git a/tests/cpp/tnativesockets.nim b/tests/cpp/tnativesockets.nim
index c62008050..1284811b5 100644
--- a/tests/cpp/tnativesockets.nim
+++ b/tests/cpp/tnativesockets.nim
@@ -1,5 +1,6 @@
 discard """
   targets: "cpp"
+outputsub: ""
 """
 
 import nativesockets
diff --git a/tests/dll/server.nim b/tests/dll/server.nim
index e6b80df88..5ce1976ce 100644
--- a/tests/dll/server.nim
+++ b/tests/dll/server.nim
@@ -1,4 +1,5 @@
 discard """
+action: compile
   cmd: "nim $target --debuginfo --hints:on --define:useNimRtl --app:lib $options $file"
 """
 
@@ -25,10 +26,3 @@ proc newOp(k: TNodeKind, a, b: PNode): PNode {.exportc: "newOp", dynlib.} =
 
 proc buildTree(x: int): PNode {.exportc: "buildTree", dynlib.} =
   result = newOp(nkMul, newOp(nkAdd, newLit(x), newLit(x)), newLit(x))
-
-when false:
-  # Test the GC:
-  for i in 0..100_000:
-    discard buildTree(2)
-
-  echo "Done"
diff --git a/tests/init/tuninit1.nim b/tests/init/tuninit1.nim
index 891f1e96c..67c0c4d8b 100644
--- a/tests/init/tuninit1.nim
+++ b/tests/init/tuninit1.nim
@@ -1,6 +1,7 @@
 discard """
-  msg: "Warning: 'y' might not have been initialized [Uninit]"
+  nimout: "Warning: 'y' might not have been initialized [Uninit]"
   line:34
+  action: compile
 """
 
 import strutils
diff --git a/tests/macros/tmemit.nim b/tests/macros/tmemit.nim
index 3a3b8734b..06ab8a1e2 100644
--- a/tests/macros/tmemit.nim
+++ b/tests/macros/tmemit.nim
@@ -1,7 +1,9 @@
 discard """
-  output: '''HELLO WORLD
+  output: '''
+HELLO WORLD
 c_func
-12'''
+12
+'''
 """
 
 import macros, strutils
diff --git a/tests/objects/tobjects.nim b/tests/objects/tobjects.nim
index 66a38960e..235e53da5 100644
--- a/tests/objects/tobjects.nim
+++ b/tests/objects/tobjects.nim
@@ -1,3 +1,12 @@
+discard """
+action: run
+input: '''
+Andreas
+Rumpf
+'''
+outputsub: "Hallo Meister!"
+"""
+
 type
   TBase = object of RootObj
     x, y: int
diff --git a/tests/osproc/ta_out.nim b/tests/osproc/ta_out.nim
index f7091a7f6..318a27d59 100644
--- a/tests/osproc/ta_out.nim
+++ b/tests/osproc/ta_out.nim
@@ -1,3 +1,14 @@
+discard """
+output: '''
+to stdout
+to stdout
+to stderr
+to stderr
+to stdout
+to stdout
+'''
+"""
+
 # This file is prefixed with an "a", because other tests
 # depend on it and it must be compiled first.
 stdout.writeLine("to stdout")
diff --git a/tests/osproc/tafalse.nim b/tests/osproc/tafalse.nim
index 24fd4fb2e..05a0bfce9 100644
--- a/tests/osproc/tafalse.nim
+++ b/tests/osproc/tafalse.nim
@@ -1,3 +1,7 @@
+discard """
+exitcode: 1
+"""
+
 # 'tafalse.nim' to ensure it is compiled before texitcode.nim
 import system
 quit(QuitFailure)
diff --git a/tests/osproc/texitcode.nim b/tests/osproc/texitcode.nim
index 4eaab6da2..6dc5508b5 100644
--- a/tests/osproc/texitcode.nim
+++ b/tests/osproc/texitcode.nim
@@ -2,6 +2,7 @@ discard """
   file: "texitcode.nim"
   output: ""
 """
+
 import osproc, os
 
 const filename = when defined(Windows): "tafalse.exe" else: "tafalse"
diff --git a/tests/stdlib/tmath2.nim b/tests/stdlib/tmath2.nim
deleted file mode 100644
index eb0506f5f..000000000
--- a/tests/stdlib/tmath2.nim
+++ /dev/null
@@ -1,85 +0,0 @@
-# tests for the interpreter
-
-proc loops(a: var int) =
-  discard
-  #var
-  #  b: int
-  #b = glob
-  #while b != 0:
-  #  b = b + 1
-  #a = b
-
-proc mymax(a, b: int): int =
-  #loops(result)
-  result = a
-  if b > a: result = b
-
-proc test(a, b: int) =
-  var
-    x, y: int
-  x = 0
-  y = 7
-  if x == a + b * 3 - 7 or
-      x == 8 or
-      x == y and y > -56 and y < 699:
-    y = 0
-  elif y == 78 and x == 0:
-    y = 1
-  elif y == 0 and x == 0:
-    y = 2
-  else:
-    y = 3
-
-type
-  TTokType = enum
-    tkNil, tkType, tkConst, tkVar, tkSymbol, tkIf,
-    tkWhile, tkFor, tkLoop, tkCase, tkLabel, tkGoto
-
-proc testCase(t: TTokType): int =
-  case t
-  of tkNil, tkType, tkConst: result = 0
-  of tkVar: result = 1
-  of tkSymbol: result = 2
-  of tkIf..tkFor: result = 3
-  of tkLoop: result = 56
-  else: result = -1
-  test(0, 9) # test the call
-
-proc TestLoops() =
-  var
-    i, j: int
-
-  while i >= 0:
-    if i mod 3 == 0:
-      break
-    i = i + 1
-    while j == 13:
-      j = 13
-      break
-    break
-
-  while true:
-    break
-
-
-var
-  glob: int
-  a: array[0..5, int]
-
-proc main() =
-  #glob = 0
-  #loops( glob )
-  var
-    res: int
-    s: string
-  #write(stdout, mymax(23, 45))
-  write(stdout, "Hallo! Wie heisst du? ")
-  s = readLine(stdin)
-  # test the case statement
-  case s
-  of "Andreas": write(stdout, "Du bist mein Meister!\n")
-  of "Rumpf": write(stdout, "Du bist in der Familie meines Meisters!\n")
-  else: write(stdout, "ich kenne dich nicht!\n")
-  write(stdout, "Du heisst " & s & "\n")
-
-main()
diff --git a/tests/stdlib/tmemfiles1.nim b/tests/stdlib/tmemfiles1.nim
index 8b66dfcc1..a18fba083 100644
--- a/tests/stdlib/tmemfiles1.nim
+++ b/tests/stdlib/tmemfiles1.nim
@@ -1,5 +1,6 @@
 discard """
   file: "tmemfiles1.nim"
+  outputsub: ""
 """
 import memfiles, os
 var
@@ -8,5 +9,5 @@ var
 # Create a new file
 mm = memfiles.open(fn, mode = fmReadWrite, newFileSize = 20)
 mm.close()
-mm.close()
+# mm.close()
 if fileExists(fn): removeFile(fn)
diff --git a/tests/stdlib/tmemlines.nim b/tests/stdlib/tmemlines.nim
index c850b5493..98e03b5bb 100644
--- a/tests/stdlib/tmemlines.nim
+++ b/tests/stdlib/tmemlines.nim
@@ -1,3 +1,7 @@
+discard """
+outputsub: ""
+"""
+
 import memfiles
 var inp = memfiles.open("tests/stdlib/tmemlines.nim")
 for line in lines(inp):
diff --git a/tests/stdlib/tmemslices.nim b/tests/stdlib/tmemslices.nim
index d724254a2..c0d6d3960 100644
--- a/tests/stdlib/tmemslices.nim
+++ b/tests/stdlib/tmemslices.nim
@@ -1,3 +1,9 @@
+discard """
+outputsub: "rlwuiadtrnzb"
+"""
+
+# chatever the sub pattern it will find itself
+
 import memfiles
 var inp = memfiles.open("tests/stdlib/tmemslices.nim")
 for mem in memSlices(inp):
diff --git a/tests/stdlib/tnet.nim b/tests/stdlib/tnet.nim
index 009561272..2dd22796c 100644
--- a/tests/stdlib/tnet.nim
+++ b/tests/stdlib/tnet.nim
@@ -1,3 +1,7 @@
+discard """
+outputsub: ""
+"""
+
 import net, nativesockets
 import unittest
 
diff --git a/tests/stdlib/tosprocterminate.nim b/tests/stdlib/tosprocterminate.nim
index 7fc6c5d85..a46d91d68 100644
--- a/tests/stdlib/tosprocterminate.nim
+++ b/tests/stdlib/tosprocterminate.nim
@@ -1,3 +1,7 @@
+discard """
+outputsub: "SUCCESS"
+"""
+
 import os, osproc
 
 when defined(Windows):
diff --git a/tests/stdlib/tposix.nim b/tests/stdlib/tposix.nim
index 57a43f99e..14f1fd6e2 100644
--- a/tests/stdlib/tposix.nim
+++ b/tests/stdlib/tposix.nim
@@ -1,3 +1,7 @@
+discard """
+outputsub: ""
+"""
+
 # Test Posix interface
 
 when not defined(windows):
@@ -13,4 +17,3 @@ when not defined(windows):
   writeLine(stdout, u.nodename)
   writeLine(stdout, u.release)
   writeLine(stdout, u.machine)
-
diff --git a/tests/stdlib/tquit.nim b/tests/stdlib/tquit.nim
index d18b468c8..4f8d5fb20 100644
--- a/tests/stdlib/tquit.nim
+++ b/tests/stdlib/tquit.nim
@@ -1,3 +1,9 @@
+discard """
+output: '''
+just exiting...
+'''
+"""
+
 # Test the new beforeQuit variable:
 
 proc myExit() {.noconv.} =
diff --git a/tests/stdlib/trepr2.nim b/tests/stdlib/trepr2.nim
index 300df565d..89379da96 100644
--- a/tests/stdlib/trepr2.nim
+++ b/tests/stdlib/trepr2.nim
@@ -1,3 +1,8 @@
+discard """
+outputsub: ""
+"""
+
+# output not testable because repr prints pointer adresses
 # test the new "repr" built-in proc
 
 type
diff --git a/tests/stdlib/trstgen.nim b/tests/stdlib/trstgen.nim
index c702ccc2a..fd89f68af 100644
--- a/tests/stdlib/trstgen.nim
+++ b/tests/stdlib/trstgen.nim
@@ -1,3 +1,7 @@
+discard """
+outputsub: ""
+"""
+
 # tests for rstgen module.
 
 import ../../lib/packages/docutils/rstgen
@@ -27,7 +31,7 @@ suite "YAML syntax highlighting":
 <span class="Punctuation">?</span> <span class="StringLit">key</span>
 <span class="Punctuation">:</span> <span class="StringLit">value</span>
 <span class="Keyword">...</span></pre>"""
-  
+
   test "Block scalars":
     let input = """.. code-block:: yaml
     a literal block scalar: |
@@ -55,7 +59,7 @@ suite "YAML syntax highlighting":
 <span class="StringLit">another literal block scalar</span><span class="Punctuation">:</span>
   <span class="Command">|+</span> <span class="Comment"># comment after header</span><span class="LongStringLit">
  allowed, since more indented than parent</span></pre>"""
- 
+
   test "Directives":
     let input = """.. code-block:: yaml
     %YAML 1.2
@@ -97,7 +101,7 @@ suite "YAML syntax highlighting":
   <span class="StringLit">more numbers</span><span class="Punctuation">:</span> <span class="Punctuation">[</span><span class="DecNumber">-783</span><span class="Punctuation">,</span> <span class="FloatNumber">11e78</span><span class="Punctuation">]</span><span class="Punctuation">,</span>
   <span class="StringLit">not numbers</span><span class="Punctuation">:</span> <span class="Punctuation">[</span> <span class="StringLit">42e</span><span class="Punctuation">,</span> <span class="StringLit">0023</span><span class="Punctuation">,</span> <span class="StringLit">+32.37</span><span class="Punctuation">,</span> <span class="StringLit">8 ball</span><span class="Punctuation">]</span>
 <span class="Punctuation">}</span></pre>"""
-  
+
   test "Anchors, Aliases, Tags":
     let input = """.. code-block:: yaml
     --- !!map
@@ -136,4 +140,4 @@ suite "YAML syntax highlighting":
   <span class="DecNumber">-3</span>
   <span class="DecNumber">-4</span>
 <span class="StringLit">example.com/not/a#comment</span><span class="Punctuation">:</span>
-  <span class="StringLit">?not a map key</span></pre>"""
\ No newline at end of file
+  <span class="StringLit">?not a map key</span></pre>"""
diff --git a/tests/stdlib/tsortcall.nim b/tests/stdlib/tsortcall.nim
index 45b98805f..242e3fe4c 100644
--- a/tests/stdlib/tsortcall.nim
+++ b/tests/stdlib/tsortcall.nim
@@ -1,3 +1,7 @@
+discard """
+outputsub: ""
+"""
+
 import algorithm
 import unittest
 
@@ -40,7 +44,7 @@ suite "test sort, sorted, and isSorted procs":
   test "test the shortcut versions with descending sort order":
     check(not unSortedIntSeq.isSorted(SortOrder.Descending))
     check sorted(unSortedIntSeq, SortOrder.Descending) == reversed sortedIntSeq
-    check sorted(unSortedIntSeq).isSorted(SortOrder.Descending)
+    check sorted(unSortedIntSeq).isSorted(SortOrder.Ascending)
 
     unSortedIntSeq.sort(SortOrder.Descending)
     check unSortedIntSeq == reversed sortedIntSeq
diff --git a/tests/stdlib/tstreams.nim b/tests/stdlib/tstreams.nim
index 16dbc0e1b..8a11a89f2 100644
--- a/tests/stdlib/tstreams.nim
+++ b/tests/stdlib/tstreams.nim
@@ -1,12 +1,24 @@
+discard """
+input: "Arne"
+output: '''
+Hello! What is your name?
+Nice name: Arne
+fs is: nil
+
+threw exception
+'''
+"""
+
+
 import streams
 
 
 block tstreams:
   var outp = newFileStream(stdout)
   var inp = newFileStream(stdin)
-  write(outp, "Hello! What is your name?")
+  writeLine(outp, "Hello! What is your name?")
   var line = readLine(inp)
-  write(outp, "Nice name: " & line)
+  writeLine(outp, "Nice name: " & line)
 
 
 block tstreams2:
diff --git a/tests/stdlib/tstrtabs.nim b/tests/stdlib/tstrtabs.nim
index a248cc3b2..18ed57167 100644
--- a/tests/stdlib/tstrtabs.nim
+++ b/tests/stdlib/tstrtabs.nim
@@ -1,3 +1,92 @@
+discard """
+sortoutput: true
+output: '''
+key1: value1
+key2: value2
+key_0: value0
+key_10: value10
+key_11: value11
+key_12: value12
+key_13: value13
+key_14: value14
+key_15: value15
+key_16: value16
+key_17: value17
+key_18: value18
+key_19: value19
+key_20: value20
+key_21: value21
+key_22: value22
+key_23: value23
+key_24: value24
+key_25: value25
+key_26: value26
+key_27: value27
+key_28: value28
+key_29: value29
+key_30: value30
+key_31: value31
+key_32: value32
+key_33: value33
+key_34: value34
+key_35: value35
+key_36: value36
+key_37: value37
+key_38: value38
+key_39: value39
+key_3: value3
+key_40: value40
+key_41: value41
+key_42: value42
+key_43: value43
+key_44: value44
+key_45: value45
+key_46: value46
+key_47: value47
+key_48: value48
+key_49: value49
+key_4: value4
+key_50: value50
+key_51: value51
+key_52: value52
+key_53: value53
+key_54: value54
+key_55: value55
+key_56: value56
+key_57: value57
+key_58: value58
+key_59: value59
+key_5: value5
+key_60: value60
+key_61: value61
+key_62: value62
+key_63: value63
+key_64: value64
+key_65: value65
+key_66: value66
+key_67: value67
+key_68: value68
+key_69: value69
+key_6: value6
+key_70: value70
+key_71: value71
+key_72: value72
+key_73: value73
+key_74: value74
+key_75: value75
+key_76: value76
+key_77: value77
+key_78: value78
+key_79: value79
+key_7: value7
+key_80: value80
+key_8: value8
+key_9: value9
+length of table 81
+value1 = value2
+'''
+"""
+
 import strtabs
 
 var tab = newStringTable({"key1": "val1", "key2": "val2"},
@@ -9,4 +98,4 @@ for key, val in pairs(tab):
   writeLine(stdout, key, ": ", val)
 writeLine(stdout, "length of table ", $tab.len)
 
-writeLine(stdout, `%`("$key1 = $key2; ${PATH}", tab, {useEnvironment}))
+writeLine(stdout, `%`("$key1 = $key2", tab, {useEnvironment}))
diff --git a/tests/stdlib/twalker.nim b/tests/stdlib/twalker.nim
deleted file mode 100644
index 91c97df01..000000000
--- a/tests/stdlib/twalker.nim
+++ /dev/null
@@ -1,13 +0,0 @@
-# iterate over all files with a given filter:
-
-import
-  "../../lib/pure/os.nim", ../../ lib / pure / times
-
-proc main(filter: string) =
-  for filename in walkFiles(filter):
-    writeLine(stdout, filename)
-
-  for key, val in envPairs():
-    writeLine(stdout, key & '=' & val)
-
-main("*.nim")
diff --git a/tests/template/ttempl3.nim b/tests/template/ttempl3.nim
index dc18108d5..943cdae05 100644
--- a/tests/template/ttempl3.nim
+++ b/tests/template/ttempl3.nim
@@ -1,9 +1,5 @@
 discard """
-output: '''
-1
-yay
-12
-'''
+action: compile
 """