diff options
Diffstat (limited to 'tests/stdlib')
-rw-r--r-- | tests/stdlib/tmath2.nim | 85 | ||||
-rw-r--r-- | tests/stdlib/tmemfiles1.nim | 3 | ||||
-rw-r--r-- | tests/stdlib/tmemlines.nim | 4 | ||||
-rw-r--r-- | tests/stdlib/tmemslices.nim | 6 | ||||
-rw-r--r-- | tests/stdlib/tnet.nim | 4 | ||||
-rw-r--r-- | tests/stdlib/tosprocterminate.nim | 4 | ||||
-rw-r--r-- | tests/stdlib/tposix.nim | 5 | ||||
-rw-r--r-- | tests/stdlib/tquit.nim | 6 | ||||
-rw-r--r-- | tests/stdlib/trepr2.nim | 5 | ||||
-rw-r--r-- | tests/stdlib/trstgen.nim | 12 | ||||
-rw-r--r-- | tests/stdlib/tsortcall.nim | 6 | ||||
-rw-r--r-- | tests/stdlib/tstreams.nim | 16 | ||||
-rw-r--r-- | tests/stdlib/tstrtabs.nim | 91 | ||||
-rw-r--r-- | tests/stdlib/twalker.nim | 13 |
14 files changed, 152 insertions, 108 deletions
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") |