diff options
author | Arne Döring <arne.doering@gmx.net> | 2018-11-14 23:14:16 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-11-23 11:58:28 +0100 |
commit | e012eb100109d343b7cdbe2598d439d84eda7830 (patch) | |
tree | ec977218e469415b04cc7005473f9f3358dcd553 /tests/misc | |
parent | 8ea72bdceab5a13318a0269bb44990e514bf03a7 (diff) | |
download | Nim-e012eb100109d343b7cdbe2598d439d84eda7830.tar.gz |
updated tests to be executed
Diffstat (limited to 'tests/misc')
-rw-r--r-- | tests/misc/tcmdline.nim | 7 | ||||
-rw-r--r-- | tests/misc/tcolonisproc.nim | 6 | ||||
-rw-r--r-- | tests/misc/tdllvar.nim | 6 | ||||
-rw-r--r-- | tests/misc/theaproots.nim | 4 | ||||
-rw-r--r-- | tests/misc/tlastmod.nim | 15 | ||||
-rw-r--r-- | tests/misc/tloops.nim | 8 | ||||
-rw-r--r-- | tests/misc/tnew.nim | 7 | ||||
-rw-r--r-- | tests/misc/tprep.nim | 8 | ||||
-rw-r--r-- | tests/misc/tquicksort.nim | 9 | ||||
-rw-r--r-- | tests/misc/tradix.nim | 25 | ||||
-rw-r--r-- | tests/misc/treadln.nim | 11 | ||||
-rw-r--r-- | tests/misc/tshadow_magic_type.nim | 10 | ||||
-rw-r--r-- | tests/misc/tstrace.nim | 20 | ||||
-rw-r--r-- | tests/misc/tstrdist.nim | 2 | ||||
-rw-r--r-- | tests/misc/tunsigned64mod.nim | 8 | ||||
-rw-r--r-- | tests/misc/tvarious.nim | 4 |
16 files changed, 130 insertions, 20 deletions
diff --git a/tests/misc/tcmdline.nim b/tests/misc/tcmdline.nim index cb8cb402c..3ccb75dcc 100644 --- a/tests/misc/tcmdline.nim +++ b/tests/misc/tcmdline.nim @@ -1,3 +1,10 @@ +discard """ +output: ''' +This exe: /home/arne/proj/nim/Nim/tests/misc/tcmdline +Number of parameters: 0 +tests/misc/tcmdline +''' +""" # Test the command line import diff --git a/tests/misc/tcolonisproc.nim b/tests/misc/tcolonisproc.nim index 665e9e604..c10dabcf1 100644 --- a/tests/misc/tcolonisproc.nim +++ b/tests/misc/tcolonisproc.nim @@ -1,3 +1,9 @@ +discard """ +output: ''' +1 +2 +''' +""" proc p(a, b: int, c: proc ()) = c() diff --git a/tests/misc/tdllvar.nim b/tests/misc/tdllvar.nim index 1c1238e8d..68029ddf4 100644 --- a/tests/misc/tdllvar.nim +++ b/tests/misc/tdllvar.nim @@ -1,3 +1,7 @@ +discard """ +disabled: true +""" + import os proc getDllName: string = @@ -12,5 +16,3 @@ proc myImport2(s: int) {.cdecl, importc, dynlib: getDllName().} myImport("test2") myImport2(12) - - diff --git a/tests/misc/theaproots.nim b/tests/misc/theaproots.nim index 77d0207b0..1ea3c86b9 100644 --- a/tests/misc/theaproots.nim +++ b/tests/misc/theaproots.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + type Bar = object x: int diff --git a/tests/misc/tlastmod.nim b/tests/misc/tlastmod.nim index c622ab518..1cc1d4bd9 100644 --- a/tests/misc/tlastmod.nim +++ b/tests/misc/tlastmod.nim @@ -1,18 +1,25 @@ +discard """ +outputsub: "is newer than" +""" # test the new LastModificationTime() proc +let + file1 = "tests/testdata/data.csv" + file2 = "tests/testdata/doc1.xml" + import os, times, strutils proc main() = var a, b: Time - a = getLastModificationTime(paramStr(1)) - b = getLastModificationTime(paramStr(2)) + a = getLastModificationTime(file1) + b = getLastModificationTime(file2) writeLine(stdout, $a) writeLine(stdout, $b) if a < b: - write(stdout, "$2 is newer than $1\n" % [paramStr(1), paramStr(2)]) + write(stdout, "$2 is newer than $1\n" % [file1, file2]) else: - write(stdout, "$1 is newer than $2\n" % [paramStr(1), paramStr(2)]) + write(stdout, "$1 is newer than $2\n" % [file1, file2]) main() diff --git a/tests/misc/tloops.nim b/tests/misc/tloops.nim index b160500af..61e0baf10 100644 --- a/tests/misc/tloops.nim +++ b/tests/misc/tloops.nim @@ -1,3 +1,10 @@ +discard """ +output: ''' +Hello!(x: 1, y: 2, z: 3) +(x: 1.0, y: 2.0) +''' +""" + # Test nested loops and some other things proc andTest() = @@ -84,4 +91,3 @@ proc main[T]() = echo myType2 main[int]() - diff --git a/tests/misc/tnew.nim b/tests/misc/tnew.nim index 89f34a621..02282dd4a 100644 --- a/tests/misc/tnew.nim +++ b/tests/misc/tnew.nim @@ -1,3 +1,10 @@ +discard """ +outputsub: ''' +Simple tree node allocation worked! +Simple cycle allocation worked! +''' +""" + # Test the implementation of the new operator # and the code generation for gc walkers # (and the garbage collector): diff --git a/tests/misc/tprep.nim b/tests/misc/tprep.nim index 8f40300d6..45f25b790 100644 --- a/tests/misc/tprep.nim +++ b/tests/misc/tprep.nim @@ -1,3 +1,11 @@ +discard """ +nimout: ''' +tprep.nim(25, 9) Hint: Case 2 [User] +tprep.nim(27, 11) Hint: Case 2.3 [User] +''' +outputsub: "" +""" + # Test the features that used to belong to the preprocessor import diff --git a/tests/misc/tquicksort.nim b/tests/misc/tquicksort.nim index 0867a3769..017c73fbc 100644 --- a/tests/misc/tquicksort.nim +++ b/tests/misc/tquicksort.nim @@ -17,10 +17,7 @@ proc echoSeq(a: seq[int]) = for i in low(a)..high(a): echo(a[i]) -var - list: seq[int] - -list = QuickSort(@[89,23,15,23,56,123,356,12,7,1,6,2,9,4,3]) -echoSeq(list) - +let list = QuickSort(@[89,23,15,23,56,123,356,12,7,1,6,2,9,4,3]) +let expected = @[1, 2, 3, 4, 6, 7, 9, 12, 15, 23, 56, 89, 123, 356] +doAssert list == expected diff --git a/tests/misc/tradix.nim b/tests/misc/tradix.nim index 07674af18..5009dfcfb 100644 --- a/tests/misc/tradix.nim +++ b/tests/misc/tradix.nim @@ -1,3 +1,28 @@ +discard """ +output: ''' +false +false +false +false +false +false +false +false +false +false +128 +1 +2 +3 +4 +255 +17 +45 +19000 +4294967288 +''' +""" + # implements and tests an efficient radix tree ## another method to store an efficient array of pointers: diff --git a/tests/misc/treadln.nim b/tests/misc/treadln.nim index 6e01097aa..b716c4711 100644 --- a/tests/misc/treadln.nim +++ b/tests/misc/treadln.nim @@ -1,3 +1,11 @@ + +discard """ +output: ''' +test the improved readline handling that does not care whether its +Macintosh, Unix or Windows text format. +''' +""" + # test the improved readline handling that does not care whether its # Macintosh, Unix or Windows text format. @@ -8,5 +16,6 @@ var if open(inp, "tests/misc/treadln.nim"): while not endOfFile(inp): line = readLine(inp) - echo("#" & line & "#") + if line.len >= 2 and line[0] == '#' and line[1] == ' ': + echo line[2..^1] close(inp) diff --git a/tests/misc/tshadow_magic_type.nim b/tests/misc/tshadow_magic_type.nim index 03c83079e..6f9716bb9 100644 --- a/tests/misc/tshadow_magic_type.nim +++ b/tests/misc/tshadow_magic_type.nim @@ -1,3 +1,10 @@ +discard """ +output: ''' +mylist +''' +""" + + type TListItemType* = enum RedisNil, RedisString @@ -15,7 +22,8 @@ proc seq*() = proc lrange*(key: string): TRedisList = var foo: TListItem - foo.kind = RedisNil + foo.kind = RedisString + foo.str = key result = @[foo] when isMainModule: diff --git a/tests/misc/tstrace.nim b/tests/misc/tstrace.nim index 23590d958..00af0af69 100644 --- a/tests/misc/tstrace.nim +++ b/tests/misc/tstrace.nim @@ -1,3 +1,23 @@ +discard """ +exitcode: 1 +output: ''' +Traceback (most recent call last) +tstrace.nim(36) tstrace +tstrace.nim(28) recTest +tstrace.nim(28) recTest +tstrace.nim(28) recTest +tstrace.nim(28) recTest +tstrace.nim(28) recTest +tstrace.nim(28) recTest +tstrace.nim(28) recTest +tstrace.nim(28) recTest +tstrace.nim(28) recTest +tstrace.nim(28) recTest +tstrace.nim(31) recTest +SIGSEGV: Illegal storage access. (Attempt to read from nil?) +''' +""" + # Test the new stacktraces (great for debugging!) {.push stack_trace: on.} diff --git a/tests/misc/tstrdist.nim b/tests/misc/tstrdist.nim index 3e1939e73..53ace2fae 100644 --- a/tests/misc/tstrdist.nim +++ b/tests/misc/tstrdist.nim @@ -23,4 +23,4 @@ proc editDistance(a, b: string): int = c[(i-1)*n + (j-1)] = min(x,min(y,z)) return c[n*m] -write(stdout, editDistance("abc", "abd")) +doAssert editDistance("abc", "abd") == 3 diff --git a/tests/misc/tunsigned64mod.nim b/tests/misc/tunsigned64mod.nim index 9c9e01c45..ca3286df3 100644 --- a/tests/misc/tunsigned64mod.nim +++ b/tests/misc/tunsigned64mod.nim @@ -12,13 +12,13 @@ let t4 = (v2 mod 2'u64).uint64 # works # bug #2550 var x: uint # doesn't work -echo x mod 2 == 0 +doAssert x mod 2 == 0 var y: uint64 # doesn't work -echo y mod 2 == 0 +doAssert y mod 2 == 0 var z: uint32 # works -echo z mod 2 == 0 +doAssert z mod 2 == 0 var a: int # works -echo a mod 2 == 0 +doAssert a mod 2 == 0 diff --git a/tests/misc/tvarious.nim b/tests/misc/tvarious.nim index 8124b3fc7..191107a87 100644 --- a/tests/misc/tvarious.nim +++ b/tests/misc/tvarious.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + # Test various aspects # bug #572 |