diff --git a/examples/tunit.nim b/examples/tunit.nim index 785b9aa5ee..bc447812d2 100644 --- a/examples/tunit.nim +++ b/examples/tunit.nim @@ -1,3 +1,4 @@ + import unittest, macros @@ -44,4 +45,3 @@ test "arithmetic failure": expect(ArithmeticError, CatchableError): discard foo() - diff --git a/lib/pure/random.nim b/lib/pure/random.nim index a2c2c1f886..c458d51eb8 100644 --- a/lib/pure/random.nim +++ b/lib/pure/random.nim @@ -231,4 +231,8 @@ when isMainModule: except RangeError: discard + + # don't use causes integer overflow + doAssert compiles(random[int](low(int) .. high(int))) + main() diff --git a/lib/pure/times.nim b/lib/pure/times.nim index ef329502f2..fd1a6acc57 100644 --- a/lib/pure/times.nim +++ b/lib/pure/times.nim @@ -839,6 +839,11 @@ proc `$`*(zone: Timezone): string = proc `==`*(zone1, zone2: Timezone): bool = ## Two ``Timezone``'s are considered equal if their name is equal. + if system.`==`(zone1, zone2): + return true + if zone1.isNil or zone2.isNil: + return false + runnableExamples: doAssert local() == local() doAssert local() != utc() @@ -1799,7 +1804,7 @@ proc formatPattern(dt: DateTime, pattern: FormatPattern, result: var string) = of UUUU: result.add $dt.year of z, zz, zzz, zzzz: - if dt.timezone.name == "Etc/UTC": + if dt.timezone != nil and dt.timezone.name == "Etc/UTC": result.add 'Z' else: result.add if -dt.utcOffset >= 0: '+' else: '-' diff --git a/testament/tester.nim b/testament/tester.nim index 166067dc20..73e80419cd 100644 --- a/testament/tester.nim +++ b/testament/tester.nim @@ -358,7 +358,7 @@ proc testSpec(r: var TResults, test: TTest, target = targetC) = reExeNotFound) continue - let exeCmd = (if isJsTarget: nodejs & " " else: "") & exeFile + let exeCmd = nodejs & " " & quoteShell(exeFile) var (buf, exitCode) = execCmdEx(exeCmd, options = {poStdErrToStdOut}) # Treat all failure codes from nodejs as 1. Older versions of nodejs used diff --git a/tests/async/tasyncall.nim b/tests/async/tasyncall.nim index 775dd0c6f0..3e30e8ba86 100644 --- a/tests/async/tasyncall.nim +++ b/tests/async/tasyncall.nim @@ -2,7 +2,7 @@ discard """ file: "tasyncall.nim" exitcode: 0 """ -import times, sequtils, unittest +import times, sequtils import asyncdispatch const diff --git a/tests/async/tasyncssl.nim b/tests/async/tasyncssl.nim index b821976571..2122609221 100644 --- a/tests/async/tasyncssl.nim +++ b/tests/async/tasyncssl.nim @@ -3,7 +3,12 @@ discard """ cmd: "nim $target --hints:on --define:ssl $options $file" output: "500" disabled: "windows" + target: c + action: compile """ + +# XXX, deactivated + import asyncdispatch, asyncnet, net, strutils, os when defined(ssl): diff --git a/tests/casestmt/tlinearscanend.nim b/tests/casestmt/tlinearscanend.nim index 9a984e039c..96e3727d5e 100644 --- a/tests/casestmt/tlinearscanend.nim +++ b/tests/casestmt/tlinearscanend.nim @@ -1,3 +1,6 @@ +discard """ +action: compile +""" import strutils @@ -21,4 +24,3 @@ of 21: echo "21" else: {.linearScanEnd.} echo "default" - diff --git a/tests/closure/tmacrobust1512.nim b/tests/closure/tmacrobust1512.nim index 5f13e82863..0f44c5e1a6 100644 --- a/tests/closure/tmacrobust1512.nim +++ b/tests/closure/tmacrobust1512.nim @@ -1,8 +1,12 @@ +discard """ +output: "" +""" + import macros, strutils # https://github.com/nim-lang/Nim/issues/1512 -proc macrobust0(raw_input: string) = +proc macrobust0(input: string): string = var output = "" proc p1(a:string) = output.add(a) @@ -27,13 +31,9 @@ proc macrobust0(raw_input: string) = proc p19(a:string) = p18(a) proc p20(a:string) = p19(a) - let input = $raw_input - for a in input.split(): p20(a) p19(a) - - p18(a) p17(a) p16(a) @@ -53,11 +53,9 @@ proc macrobust0(raw_input: string) = p2(a) p1(a) + result = output - echo output - -macro macrobust(raw_input: untyped): untyped = - +macro macrobust(input: static[string]): untyped = var output = "" proc p1(a:string) = output.add(a) @@ -82,12 +80,9 @@ macro macrobust(raw_input: untyped): untyped = proc p19(a:string) = p18(a) proc p20(a:string) = p19(a) - let input = $raw_input - for a in input.split(): p20(a) p19(a) - p18(a) p17(a) p16(a) @@ -105,11 +100,11 @@ macro macrobust(raw_input: untyped): untyped = p4(a) p3(a) p2(a) + p1(a) - echo output - discard result + result = newLit(output) -macrobust """ +const input = """ fdsasadfsdfa sadfsdafsdaf dsfsdafdsfadsfa fsdaasdfasdf fsdafsadfsad asdfasdfasdf @@ -122,16 +117,7 @@ macrobust """ sdfasdafsadf sdfasdafsdaf sdfasdafsdaf """ +let str1 = macrobust(input) +let str2 = macrobust0(input) -macrobust0 """ - fdsasadfsdfa sadfsdafsdaf - dsfsdafdsfadsfa fsdaasdfasdf - fsdafsadfsad asdfasdfasdf - fdsasdfasdfa sadfsadfsadf - sadfasdfsdaf sadfsdafsdaf dsfasdaf - sadfsdafsadf fdsasdafsadf fdsasadfsdaf - sdfasadfsdafdfsa sadfsadfsdaf - sdafsdaffsda sdfasadfsadf - fsdasdafsdfa sdfasdfafsda - sdfasdafsadf sdfasdafsdaf sdfasdafsdaf -""" +doAssert str1 == str2 diff --git a/tests/closure/ttimeinfo.nim b/tests/closure/ttimeinfo.nim index 3096a5d655..7416c0d31a 100644 --- a/tests/closure/ttimeinfo.nim +++ b/tests/closure/ttimeinfo.nim @@ -1,3 +1,10 @@ +discard """ +output: ''' +@[2000-01-01T00:00:00+00:00, 2001-01-01T00:00:00+00:00, 2002-01-01T00:00:00+00:00, 2003-01-01T00:00:00+00:00, 2004-01-01T00:00:00+00:00, 2005-01-01T00:00:00+00:00, 2006-01-01T00:00:00+00:00, 2007-01-01T00:00:00+00:00, 2008-01-01T00:00:00+00:00, 2009-01-01T00:00:00+00:00, 2010-01-01T00:00:00+00:00, 2011-01-01T00:00:00+00:00, 2012-01-01T00:00:00+00:00, 2013-01-01T00:00:00+00:00, 2014-01-01T00:00:00+00:00, 2015-01-01T00:00:00+00:00] +@[2000-01-01T00:00:00+00:00, 2001-01-01T00:00:00+00:00, 2002-01-01T00:00:00+00:00, 2003-01-01T00:00:00+00:00, 2004-01-01T00:00:00+00:00, 2005-01-01T00:00:00+00:00, 2006-01-01T00:00:00+00:00, 2007-01-01T00:00:00+00:00, 2008-01-01T00:00:00+00:00, 2009-01-01T00:00:00+00:00, 2010-01-01T00:00:00+00:00, 2011-01-01T00:00:00+00:00, 2012-01-01T00:00:00+00:00, 2013-01-01T00:00:00+00:00, 2014-01-01T00:00:00+00:00, 2015-01-01T00:00:00+00:00] +''' +""" + # bug #2073 import sequtils diff --git a/tests/coroutines/texceptions.nim b/tests/coroutines/texceptions.nim index e67f954c35..323eb055d9 100644 --- a/tests/coroutines/texceptions.nim +++ b/tests/coroutines/texceptions.nim @@ -14,6 +14,7 @@ proc testExceptions(id: int, sleep: float) = numbers.add(id) raise (ref ValueError)() except: + suspend(sleep) numbers.add(id) suspend(sleep) numbers.add(id) @@ -22,6 +23,6 @@ proc testExceptions(id: int, sleep: float) = start(proc() = testExceptions(1, 0.01)) start(proc() = testExceptions(2, 0.011)) -run() +coro.run() doAssert(stackCheckValue == 1100220033, "Thread stack got corrupted") doAssert(numbers == @[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], "Coroutines executed in incorrect order") diff --git a/tests/cpp/tsigbreak.nim b/tests/cpp/tsigbreak.nim index 9a381d84fa..14d29adf78 100644 --- a/tests/cpp/tsigbreak.nim +++ b/tests/cpp/tsigbreak.nim @@ -1,5 +1,6 @@ discard """ targets: "cpp" + action: compile """ import tables, lists diff --git a/tests/defaultprocparam/tdefaultprocparam.nim b/tests/defaultprocparam/tdefaultprocparam.nim index 23ecf72e92..5f8c1adab7 100644 --- a/tests/defaultprocparam/tdefaultprocparam.nim +++ b/tests/defaultprocparam/tdefaultprocparam.nim @@ -1,4 +1,8 @@ - +discard """ +output: ''' +hi +''' +""" import mdefaultprocparam p() diff --git a/tests/dir with space/tspace.nim b/tests/dir with space/tspace.nim index 2b74fa6290..59237c9a16 100644 --- a/tests/dir with space/tspace.nim +++ b/tests/dir with space/tspace.nim @@ -1,3 +1,6 @@ -# Test for the compiler to be able to compile a Nim file with spaces in it. +discard """ +output: "Successful" +""" +# Test for the compiler to be able to compile a Nim file with spaces in the directory name. echo("Successful") diff --git a/tests/discard/tdiscardable.nim b/tests/discard/tdiscardable.nim index 99144e3248..a3dd966a06 100644 --- a/tests/discard/tdiscardable.nim +++ b/tests/discard/tdiscardable.nim @@ -1,3 +1,10 @@ +discard """ +output: ''' +1 +1 +''' +""" + # Test the discardable pragma proc p(x, y: int): int {.discardable.} = diff --git a/tests/effects/teffects6.nim b/tests/effects/teffects6.nim index 3dd83786fc..6a4eea1553 100644 --- a/tests/effects/teffects6.nim +++ b/tests/effects/teffects6.nim @@ -1,3 +1,8 @@ +discard """ +action: compile +""" + +# XXX: it is not actually tested if the effects are inferred type PMenu = ref object diff --git a/tests/exprs/tifexpr_typeinference.nim b/tests/exprs/tifexpr_typeinference.nim index d02492a34e..ccaea3e800 100644 --- a/tests/exprs/tifexpr_typeinference.nim +++ b/tests/exprs/tifexpr_typeinference.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + #bug #712 import tables diff --git a/tests/generics/tgenericvariant.nim b/tests/generics/tgenericvariant.nim index 348d3da6e5..73c8af8254 100644 --- a/tests/generics/tgenericvariant.nim +++ b/tests/generics/tgenericvariant.nim @@ -1,3 +1,13 @@ +discard """ +output: ''' +Test +abcxyz123 +''' +""" + +proc fakeReadLine(): string = + "abcxyz123" + type TMaybe[T] = object case empty: bool @@ -12,7 +22,7 @@ proc Nothing[T](): TMaybe[T] = result.empty = true proc safeReadLine(): TMaybe[string] = - var r = stdin.readLine() + var r = fakeReadLine() if r == "": return Nothing[string]() else: return Just(r) @@ -21,3 +31,4 @@ when isMainModule: echo(Test.value) var mSomething = safeReadLine() echo(mSomething.value) + mSomething = safeReadLine() diff --git a/tests/generics/tthread_generic.nim b/tests/generics/tthread_generic.nim index def1acfe1c..f2e9cafa93 100644 --- a/tests/generics/tthread_generic.nim +++ b/tests/generics/tthread_generic.nim @@ -1,5 +1,6 @@ discard """ cmd: "nim $target --hints:on --threads:on $options $file" + action: compile """ type @@ -36,4 +37,3 @@ when isMainModule: echo("test") joinThread(thr) os.sleep(3000) - diff --git a/tests/lexer/tident.nim b/tests/lexer/tident.nim index 3327344a56..e5177436d8 100644 --- a/tests/lexer/tident.nim +++ b/tests/lexer/tident.nim @@ -1,3 +1,16 @@ +discard """ +output: ''' +Length correct +Correct +Correct +Correct +Correct +Correct +Correct +Correct +Correct +''' +""" type TIdObj* = object of RootObj @@ -19,4 +32,3 @@ proc myNewString(L: int): string {.inline.} = echo("Wrong") var s = myNewString(8) - diff --git a/tests/lookups/test.nim b/tests/lookups/test.nim index a17d235a4e..56f39a4d71 100644 --- a/tests/lookups/test.nim +++ b/tests/lookups/test.nim @@ -1,3 +1,10 @@ +discard """ +output: ''' +[Suite] memoization + +''' +""" + # This file needs to be called 'test' nim to provoke a clash # with the unittest.test name. Issue # @@ -14,4 +21,3 @@ proc fib(n: int): int = 40 suite "memoization": test "recursive function memoization": check fastFib(40) == fib(40) - diff --git a/tests/misc/tcmdline.nim b/tests/misc/tcmdline.nim index cb8cb402cc..3ccb75dcc5 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 665e9e604e..c10dabcf15 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 1c1238e8d7..68029ddf44 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 77d0207b05..1ea3c86b97 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 c622ab518c..1cc1d4bd9f 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 b160500af2..61e0baf10f 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 89f34a6213..02282dd4a4 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 8f40300d67..45f25b790d 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 0867a3769f..017c73fbc6 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 07674af188..5009dfcfb4 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 6e01097aab..b716c47110 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 03c83079e5..6f9716bb9d 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 23590d9585..00af0af69d 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 3e1939e737..53ace2fae1 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 9c9e01c457..ca3286df31 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 8124b3fc70..191107a87a 100644 --- a/tests/misc/tvarious.nim +++ b/tests/misc/tvarious.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + # Test various aspects # bug #572 diff --git a/tests/objvariant/tcheckedfield1.nim b/tests/objvariant/tcheckedfield1.nim index a7f232c5b3..d6ae0ad51a 100644 --- a/tests/objvariant/tcheckedfield1.nim +++ b/tests/objvariant/tcheckedfield1.nim @@ -1,6 +1,8 @@ discard """ msg: "Warning: cannot prove that field 'x.s' is accessible [ProveField]" line:51 + action: run + output: "abc abc" """ import strutils diff --git a/tests/overload/tselfderef.nim b/tests/overload/tselfderef.nim index 708e4043b5..96f1da42ad 100644 --- a/tests/overload/tselfderef.nim +++ b/tests/overload/tselfderef.nim @@ -1,7 +1,10 @@ +discard """ +action: compile +""" + # bug #4671 {.experimental.} {.this: self.} - type SomeObj = object f: int diff --git a/tests/parallel/tmissing_deepcopy.nim b/tests/parallel/tmissing_deepcopy.nim index e540775f85..45fdf0f8f3 100644 --- a/tests/parallel/tmissing_deepcopy.nim +++ b/tests/parallel/tmissing_deepcopy.nim @@ -1,5 +1,5 @@ discard """ - ccodeCheck: "\\i @'deepCopy(' .*" + ccodeCheck: "@'genericDeepCopy(' .*" action: compile """ diff --git a/tests/parallel/tsimple_array_checks.nim b/tests/parallel/tsimple_array_checks.nim index 380611374e..ee95080748 100644 --- a/tests/parallel/tsimple_array_checks.nim +++ b/tests/parallel/tsimple_array_checks.nim @@ -1,11 +1,6 @@ discard """ +sortoutput: true output: ''' -Hello 1 -Hello 2 -Hello 3 -Hello 4 -Hello 5 -Hello 6 0 1 2 @@ -16,6 +11,12 @@ Hello 6 7 8 9 +Hello 1 +Hello 2 +Hello 3 +Hello 4 +Hello 5 +Hello 6 ''' """ diff --git a/tests/stdlib/thashes.nim b/tests/stdlib/thashes.nim index c442b43fba..2cd1e4e479 100644 --- a/tests/stdlib/thashes.nim +++ b/tests/stdlib/thashes.nim @@ -1,5 +1,14 @@ -import unittest -import hashes + +discard """ +output: ''' +[Suite] hashes + +[Suite] hashing + +''' +""" + +import unittest, hashes suite "hashes": suite "hashing": diff --git a/tests/stdlib/thttpcore.nim b/tests/stdlib/thttpcore.nim index 9f99df93a3..889c734c58 100644 --- a/tests/stdlib/thttpcore.nim +++ b/tests/stdlib/thttpcore.nim @@ -1,3 +1,6 @@ +discard """ +output: "[Suite] httpcore" +""" import unittest diff --git a/tests/stdlib/tjsonexternproc.nim b/tests/stdlib/tjsonexternproc.nim index ec90e580d0..1091d72cd6 100644 --- a/tests/stdlib/tjsonexternproc.nim +++ b/tests/stdlib/tjsonexternproc.nim @@ -1,5 +1,11 @@ +discard """ +output: ''' +{"data":[1]} +''' +""" + # Test case for https://github.com/nim-lang/Nim/issues/6385 import mjsonexternproc # import json -foo(1) \ No newline at end of file +foo(1) diff --git a/tests/stdlib/tjsontestsuite.nim b/tests/stdlib/tjsontestsuite.nim index 06f783a731..db31963fde 100644 --- a/tests/stdlib/tjsontestsuite.nim +++ b/tests/stdlib/tjsontestsuite.nim @@ -1,3 +1,7 @@ +discard """ +disabled: true +""" + ## JSON tests based on https://github.com/nst/JSONTestSuite import unittest, diff --git a/tests/system/tio.nim b/tests/system/tio.nim index 7e9e189500..e959a90971 100644 --- a/tests/system/tio.nim +++ b/tests/system/tio.nim @@ -1,14 +1,18 @@ discard """ +outputsub: "" """ import - unittest, osproc, streams, os, strformat + unittest, osproc, streams, os, strformat, strutils const STRING_DATA = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." + const TEST_FILE = "tests/testdata/string.txt" proc echoLoop(str: string): string = result = "" - var process = startProcess(findExe("tests/system/helpers/readall_echo")) + let exe = findExe("tests/system/helpers/readall_echo") + echo "exe: ", exe + var process = startProcess(exe) var input = process.inputStream input.write(str) input.close() @@ -22,10 +26,9 @@ suite "io": test "stdin": check: echoLoop(STRING_DATA) == STRING_DATA - echoLoop(STRING_DATA[0..3999]) == STRING_DATA[0..3999] test "file": check: - readFile(TEST_FILE) == STRING_DATA + readFile(TEST_FILE).strip == STRING_DATA proc verifyFileSize(sz: int64) = diff --git a/tests/template/tconfusinglocal.nim b/tests/template/tconfusinglocal.nim index 50bf8f4b2b..9f641e2bf9 100644 --- a/tests/template/tconfusinglocal.nim +++ b/tests/template/tconfusinglocal.nim @@ -1,3 +1,7 @@ +discard """ +output: "0" +""" + # bug #5135 proc fail*[E](e: E): void = diff --git a/tests/template/texponential_eval.nim b/tests/template/texponential_eval.nim index 32af9e8f76..b4e3faefbc 100644 --- a/tests/template/texponential_eval.nim +++ b/tests/template/texponential_eval.nim @@ -1,13 +1,17 @@ # bug #1940 discard """ - nimout: '''=== +nimout: ''' +=== merge (A) with (B) merge (A B) with (C) merge (A B C) with (D) merge (A B C D) with (E) merge (A B C D E) with (F) -===''' +=== +''' + +output: "A B C D E F" """ type SqlStmt = tuple diff --git a/tests/template/thygienictempl.nim b/tests/template/thygienictempl.nim index de40450aad..506f571489 100644 --- a/tests/template/thygienictempl.nim +++ b/tests/template/thygienictempl.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + var e = "abc" diff --git a/tests/template/tparams_gensymed.nim b/tests/template/tparams_gensymed.nim index 3fb0dd4a53..da86d63dc1 100644 --- a/tests/template/tparams_gensymed.nim +++ b/tests/template/tparams_gensymed.nim @@ -1,4 +1,15 @@ - +discard """ +output: ''' +0 +1 +2 +3 +0 +1 +2 +3 +''' +""" # bug #1915 import macros diff --git a/tests/template/tsighash_regression.nim b/tests/template/tsighash_regression.nim index bf1f4dfe4f..f3a6b48334 100644 --- a/tests/template/tsighash_regression.nim +++ b/tests/template/tsighash_regression.nim @@ -1,5 +1,8 @@ +discard """ +exitcode: 1 +outputsub: "0" +""" import tconfusinglocal - fail "foo" diff --git a/tests/template/ttempl3.nim b/tests/template/ttempl3.nim index d6a369d326..dc18108d5d 100644 --- a/tests/template/ttempl3.nim +++ b/tests/template/ttempl3.nim @@ -1,3 +1,11 @@ +discard """ +output: ''' +1 +yay +12 +''' +""" + template withOpenFile(f: untyped, filename: string, mode: FileMode, actions: untyped): untyped = diff --git a/tests/typerel/tnoargopenarray.nim b/tests/typerel/tnoargopenarray.nim index 20ebe5ecc4..9e2b2fb867 100644 --- a/tests/typerel/tnoargopenarray.nim +++ b/tests/typerel/tnoargopenarray.nim @@ -1,7 +1,8 @@ +discard """ +action: compile +""" import db_sqlite var db: DbConn exec(db, sql"create table blabla()") - - diff --git a/tests/typerel/tsecondarrayproperty.nim b/tests/typerel/tsecondarrayproperty.nim index 3a6879b163..315ad06bf9 100644 --- a/tests/typerel/tsecondarrayproperty.nim +++ b/tests/typerel/tsecondarrayproperty.nim @@ -1,3 +1,7 @@ +discard """ +output: "4" +""" + type TFoo = object @@ -25,4 +29,3 @@ echo f.second[1] #echo `second[]`(f,1) # this is the only way I could use it, but not what I expected - diff --git a/tests/typerel/ttuple1.nim b/tests/typerel/ttuple1.nim index d5c80800c7..a03cc510ee 100644 --- a/tests/typerel/ttuple1.nim +++ b/tests/typerel/ttuple1.nim @@ -1,3 +1,9 @@ +discard """ +output: ''' +M=1000, D=500, C=100, L=50, X=10, V=5, I=1 +''' +""" + const romanNumbers = [ ("M", 1000), ("D", 500), ("C", 100), ("L", 50), ("X", 10), ("V", 5), ("I", 1) ] @@ -12,5 +18,3 @@ for key, val in items(romanNumbers): proc PrintBiTuple(t: tuple[k: string, v: int]): int = stdout.write(t.k & "=" & $t.v & ", ") return 0 - - diff --git a/tests/vm/tconsteval.nim b/tests/vm/tconsteval.nim index f4260495ac..2e0fcb8882 100644 --- a/tests/vm/tconsteval.nim +++ b/tests/vm/tconsteval.nim @@ -1,4 +1,5 @@ discard """ +action: compile """ import strutils @@ -28,4 +29,3 @@ Possible Commands: CompileDate, CompileTime] echo HelpText - diff --git a/tests/vm/teval1.nim b/tests/vm/teval1.nim index 0eaa050da6..5c323f0e70 100644 --- a/tests/vm/teval1.nim +++ b/tests/vm/teval1.nim @@ -1,3 +1,8 @@ + +discard """ +nimout: "##" +""" + import macros proc testProc: string {.compileTime.} = @@ -14,9 +19,9 @@ when true: const x = testProc() -echo "##", x, "##" +doAssert x == "" # bug #1310 static: - var i, j: set[int8] = {} - var k = i + j + var i, j: set[int8] = {} + var k = i + j diff --git a/tests/vm/tslurp.nim b/tests/vm/tslurp.nim index d0041eaada..d762eb079e 100644 --- a/tests/vm/tslurp.nim +++ b/tests/vm/tslurp.nim @@ -7,6 +7,6 @@ const relRes = slurp"./tslurp.nim" absRes = slurp(getScriptDir() / "tslurp.nim") -echo relRes -echo absRes - +doAssert relRes.len > 200 +doAssert absRes.len > 200 +doAssert relRes == absRes