diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/collections/ttables.nim | 33 | ||||
-rw-r--r-- | tests/js/tconsole.nim | 13 | ||||
-rw-r--r-- | tests/macros/tdump.nim | 13 | ||||
-rw-r--r-- | tests/testament/categories.nim | 10 | ||||
-rw-r--r-- | tests/testament/tester.nim | 2 | ||||
-rw-r--r-- | tests/vm/tgorge.bat | 1 | ||||
-rw-r--r-- | tests/vm/tgorge.nim | 12 | ||||
-rwxr-xr-x | tests/vm/tgorge.sh | 2 |
8 files changed, 83 insertions, 3 deletions
diff --git a/tests/collections/ttables.nim b/tests/collections/ttables.nim index 59fef4920..4f286d0ed 100644 --- a/tests/collections/ttables.nim +++ b/tests/collections/ttables.nim @@ -95,9 +95,24 @@ block orderedTableTest1: for key, val in mpairs(t): val = 99 for val in mvalues(t): assert val == 99 +block orderedTableTest2: + var + s = initOrderedTable[string, int]() + t = initOrderedTable[string, int]() + assert s == t + for key, val in items(data): t[key] = val + assert s != t + for key, val in items(sorteddata): s[key] = val + assert s != t + t.clear() + assert s != t + for key, val in items(sorteddata): t[key] = val + assert s == t + block countTableTest1: var s = data.toTable var t = initCountTable[string]() + for k in s.keys: t.inc(k) for k in t.keys: assert t[k] == 1 t.inc("90", 3) @@ -115,6 +130,24 @@ block countTableTest1: else: break inc i +block countTableTest2: + var + s = initCountTable[int]() + t = initCountTable[int]() + assert s == t + s.inc(1) + assert s != t + t.inc(2) + assert s != t + t.inc(1) + assert s != t + s.inc(2) + assert s == t + s.inc(1) + assert s != t + t.inc(1) + assert s == t + block mpairsTableTest1: var t = initTable[string, int]() t["a"] = 1 diff --git a/tests/js/tconsole.nim b/tests/js/tconsole.nim new file mode 100644 index 000000000..f6da71c20 --- /dev/null +++ b/tests/js/tconsole.nim @@ -0,0 +1,13 @@ +discard """ + output: '''Hello, console +1 2 3 +1 'hi' 1.1''' +""" + +# This file tests the JavaScript console + +import jsconsole + +console.log("Hello, console") +console.log(1, 2, 3) +console.log(1, "hi", 1.1) \ No newline at end of file diff --git a/tests/macros/tdump.nim b/tests/macros/tdump.nim new file mode 100644 index 000000000..e4c14dc6b --- /dev/null +++ b/tests/macros/tdump.nim @@ -0,0 +1,13 @@ +discard """ + output: '''x = 10 +x + y = 30 +''' +""" + +import future + +let + x = 10 + y = 20 +dump x +dump(x + y) \ No newline at end of file diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 2b0b55c0b..809425653 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -382,8 +382,14 @@ proc `&.?`(a, b: string): string = proc `&?.`(a, b: string): string = # candidate for the stdlib? result = if a.endswith(b): a else: a & b + +proc processSingleTest(r: var TResults, cat: Category, options, test: string) = + let test = "tests" & DirSep &.? cat.string / test -proc processCategory(r: var TResults, cat: Category, options: string, fileGlob: string = "t*.nim") = + if existsFile(test): testSpec r, makeTest(test, options, cat) + else: echo "[Warning] - ", test, " test does not exist" + +proc processCategory(r: var TResults, cat: Category, options: string) = case cat.string.normalize of "rodfiles": when false: compileRodFiles(r, cat, options) @@ -424,5 +430,5 @@ proc processCategory(r: var TResults, cat: Category, options: string, fileGlob: # We can't test it because it depends on a third party. discard # TODO: Move untestable tests to someplace else, i.e. nimble repo. else: - for name in os.walkFiles("tests" & DirSep &.? cat.string / fileGlob): + for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"): testSpec r, makeTest(name, options, cat) diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim index 74ac58927..2734742f4 100644 --- a/tests/testament/tester.nim +++ b/tests/testament/tester.nim @@ -445,7 +445,7 @@ proc main() = let (dir, file) = splitPath(p.key.string) let (_, subdir) = splitPath(dir) var cat = Category(subdir) - processCategory(r, cat, p.cmdLineRest.string, file) + processSingleTest(r, cat, p.cmdLineRest.string, file) of "html": var commit = 0 discard parseInt(p.cmdLineRest.string, commit) diff --git a/tests/vm/tgorge.bat b/tests/vm/tgorge.bat new file mode 100644 index 000000000..24d365842 --- /dev/null +++ b/tests/vm/tgorge.bat @@ -0,0 +1 @@ +@echo gorge test \ No newline at end of file diff --git a/tests/vm/tgorge.nim b/tests/vm/tgorge.nim new file mode 100644 index 000000000..aeaf54df8 --- /dev/null +++ b/tests/vm/tgorge.nim @@ -0,0 +1,12 @@ +import os + +template getScriptDir(): string = + parentDir(instantiationInfo(-1, true).filename) + +const + execName = when defined(windows): "tgorge.bat" else: "./tgorge.sh" + relOutput = gorge(execName) + absOutput = gorge(getScriptDir() / execName) + +doAssert relOutput == "gorge test" +doAssert absOutput == "gorge test" \ No newline at end of file diff --git a/tests/vm/tgorge.sh b/tests/vm/tgorge.sh new file mode 100755 index 000000000..ba47afeae --- /dev/null +++ b/tests/vm/tgorge.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo "gorge test" \ No newline at end of file |