diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ccgbugs/pkg8616/rtarray.nim | 2 | ||||
-rw-r--r-- | tests/ccgbugs/pkg8616/scheduler.nim | 10 | ||||
-rw-r--r-- | tests/ccgbugs/t8616.nim | 4 | ||||
-rw-r--r-- | tests/closure/t8550.nim | 12 | ||||
-rw-r--r-- | tests/converter/tconverter_with_constraint.nim | 20 | ||||
-rw-r--r-- | tests/stdlib/tstrutil.nim | 9 | ||||
-rw-r--r-- | tests/testament/categories.nim | 4 | ||||
-rw-r--r-- | tests/testament/tester.nim | 2 |
8 files changed, 61 insertions, 2 deletions
diff --git a/tests/ccgbugs/pkg8616/rtarray.nim b/tests/ccgbugs/pkg8616/rtarray.nim new file mode 100644 index 000000000..286dbb8cd --- /dev/null +++ b/tests/ccgbugs/pkg8616/rtarray.nim @@ -0,0 +1,2 @@ +proc head*[T](pp: var array[1,T]): var T = + result = pp[0] diff --git a/tests/ccgbugs/pkg8616/scheduler.nim b/tests/ccgbugs/pkg8616/scheduler.nim new file mode 100644 index 000000000..0730000c4 --- /dev/null +++ b/tests/ccgbugs/pkg8616/scheduler.nim @@ -0,0 +1,10 @@ +import rtarray + +type + T = tuple[x:int] + +var + arr: array[1,T] + +proc init*() = + discard head(arr) diff --git a/tests/ccgbugs/t8616.nim b/tests/ccgbugs/t8616.nim new file mode 100644 index 000000000..54068652a --- /dev/null +++ b/tests/ccgbugs/t8616.nim @@ -0,0 +1,4 @@ +import pkg8616 / scheduler + +when isMainModule: + init() diff --git a/tests/closure/t8550.nim b/tests/closure/t8550.nim new file mode 100644 index 000000000..153246f08 --- /dev/null +++ b/tests/closure/t8550.nim @@ -0,0 +1,12 @@ +discard """ + output: "@[\"42\"]" +""" + +proc chk_fail(): seq[string] = + iterator x(): int {.closure.} = yield 42 + proc f(cl: iterator(): int {.closure.}): seq[string] = + result = @[] + for i in cl(): result.add($i) + result = f(x) + +echo(chk_fail()) diff --git a/tests/converter/tconverter_with_constraint.nim b/tests/converter/tconverter_with_constraint.nim new file mode 100644 index 000000000..793264434 --- /dev/null +++ b/tests/converter/tconverter_with_constraint.nim @@ -0,0 +1,20 @@ + +discard """ + file: "tconverter_with_constraint.nim" + line: 20 + errormsg: "type mismatch: got <int>" +""" + +type + MyType = distinct int + +converter to_mytype(m: int{lit}): MyType = + m.MyType + +proc myproc(m: MyType) = + echo m.int, ".MyType" + +myproc(1) # call by literal is ok + +var x: int = 12 +myproc(x) # should fail \ No newline at end of file diff --git a/tests/stdlib/tstrutil.nim b/tests/stdlib/tstrutil.nim index 4d4081d39..f0ee755f7 100644 --- a/tests/stdlib/tstrutil.nim +++ b/tests/stdlib/tstrutil.nim @@ -199,6 +199,12 @@ proc testRFind = assert "0123456789ABCDEFGAH".rfind({'A'..'C'}, 13) == 12 assert "0123456789ABCDEFGAH".rfind({'G'..'H'}, 13) == -1 +proc testSplitLines() = + let fixture = "a\nb\rc\r\nd" + assert len(fixture.splitLines) == 4 + assert splitLines(fixture) == @["a", "b", "c", "d"] + assert splitLines(fixture, keepEol=true) == @["a\n", "b\r", "c\r\n", "d"] + proc testCountLines = proc assertCountLines(s: string) = assert s.countLines == s.splitLines.len assertCountLines("") @@ -229,7 +235,7 @@ proc testParseInts = assert "72".parseHexInt == 114 assert "FF".parseHexInt == 255 assert "ff".parseHexInt == 255 - assert "fF".parseHexInt == 255 + assert "fF".parseHexInt == 255 assert "0x7_2".parseHexInt == 114 rejectParse "".parseHexInt rejectParse "_".parseHexInt @@ -252,6 +258,7 @@ proc testParseInts = testDelete() testFind() testRFind() +testSplitLines() testCountLines() testParseInts() diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index fc2f0d25f..f06a23efe 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -527,5 +527,9 @@ proc processCategory(r: var TResults, cat: Category, options: string) = # 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: + var testsRun = 0 for name in os.walkFiles("tests" & DirSep &.? cat.string / "t*.nim"): testSpec r, makeTest(name, options, cat) + inc testsRun + if testsRun == 0: + echo "[Warning] - Invalid category specified \"", cat.string, "\", no tests were run" diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim index 136a509e4..9558257a6 100644 --- a/tests/testament/tester.nim +++ b/tests/testament/tester.nim @@ -22,7 +22,7 @@ const Command: all run all tests - c|category <category> run all the tests of a certain category + c|cat|category <category> run all the tests of a certain category r|run <test> run single test file html generate $1 from the database Arguments: |