diff options
Diffstat (limited to 'tests')
47 files changed, 307 insertions, 41 deletions
diff --git a/tests/async/tasyncssl.nim b/tests/async/tasyncssl.nim index 61f0b5661..b82197657 100644 --- a/tests/async/tasyncssl.nim +++ b/tests/async/tasyncssl.nim @@ -63,5 +63,3 @@ when defined(ssl): assert msgCount == swarmSize * messagesToSend echo msgCount - - diff --git a/tests/async/tfuturevar.nim b/tests/async/tfuturevar.nim index ea2c63e03..9e3134261 100644 --- a/tests/async/tfuturevar.nim +++ b/tests/async/tfuturevar.nim @@ -1,3 +1,8 @@ +discard """ +action: compile +""" +# XXX: action should be run! + import asyncdispatch proc completeOnReturn(fut: FutureVar[string], x: bool) {.async.} = @@ -44,4 +49,3 @@ proc main() {.async.} = waitFor main() - diff --git a/tests/ccgbugs/t6756.nim b/tests/ccgbugs/t6756.nim index 0f08557eb..5170a99f4 100644 --- a/tests/ccgbugs/t6756.nim +++ b/tests/ccgbugs/t6756.nim @@ -1,3 +1,9 @@ +discard """ +output: ''' +(v: 3) +''' +""" + import typetraits type A[T] = ref object diff --git a/tests/ccgbugs/tcodegendecllambda.nim b/tests/ccgbugs/tcodegendecllambda.nim index 6dce68db5..5c6608b77 100644 --- a/tests/ccgbugs/tcodegendecllambda.nim +++ b/tests/ccgbugs/tcodegendecllambda.nim @@ -1,6 +1,7 @@ discard """ targets: "c cpp js" ccodecheck: "'HELLO'" + action: compile """ when defined(JS): diff --git a/tests/ccgbugs/tgeneric_closure.nim b/tests/ccgbugs/tgeneric_closure.nim index f9d5e7910..bb3b924b9 100644 --- a/tests/ccgbugs/tgeneric_closure.nim +++ b/tests/ccgbugs/tgeneric_closure.nim @@ -1,4 +1,10 @@ - +discard """ +output: ''' +2 +2 +2 +''' +""" # bug 2659 diff --git a/tests/ccgbugs/trecursive_closure.nim b/tests/ccgbugs/trecursive_closure.nim index f64382a8c..4b6514b90 100644 --- a/tests/ccgbugs/trecursive_closure.nim +++ b/tests/ccgbugs/trecursive_closure.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + # bug #2233 type MalType = object fun: proc: MalType diff --git a/tests/ccgbugs/tsighash_typename_regression.nim b/tests/ccgbugs/tsighash_typename_regression.nim index 7122902d9..6e49bafc3 100644 --- a/tests/ccgbugs/tsighash_typename_regression.nim +++ b/tests/ccgbugs/tsighash_typename_regression.nim @@ -1,3 +1,10 @@ +discard """ +output: ''' +123 +baz +''' +""" + # bug #5147 proc foo[T](t: T) = diff --git a/tests/ccgbugs/tuple_canon.nim b/tests/ccgbugs/tuple_canon.nim index 7e9e91836..671986054 100644 --- a/tests/ccgbugs/tuple_canon.nim +++ b/tests/ccgbugs/tuple_canon.nim @@ -1,4 +1,9 @@ - +discard """ +output: ''' +vidx 18 +0,0 +''' +""" # bug #4626 var foo: (int, array[1, int]) # Tuple must be of length > 1 diff --git a/tests/compiles/trecursive_generic_in_compiles.nim b/tests/compiles/trecursive_generic_in_compiles.nim index 9c7fd10b3..c435ebaac 100644 --- a/tests/compiles/trecursive_generic_in_compiles.nim +++ b/tests/compiles/trecursive_generic_in_compiles.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + # bug #3313 import unittest, sugar {.experimental: "notnil".} diff --git a/tests/converter/t7098.nim b/tests/converter/t7098.nim index 66e629fa8..8e7634882 100644 --- a/tests/converter/t7098.nim +++ b/tests/converter/t7098.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + type Byte* = uint8 Bytes* = seq[Byte] diff --git a/tests/converter/tconvcolors.nim b/tests/converter/tconvcolors.nim index 07e829550..7b440cabd 100644 --- a/tests/converter/tconvcolors.nim +++ b/tests/converter/tconvcolors.nim @@ -1,5 +1,7 @@ +discard """ +output: "16777215A" +""" import colors echo int32(colWhite), 'A' - diff --git a/tests/converter/tgenericconverter2.nim b/tests/converter/tgenericconverter2.nim index ae064d852..017651a6b 100644 --- a/tests/converter/tgenericconverter2.nim +++ b/tests/converter/tgenericconverter2.nim @@ -1,4 +1,36 @@ # bug #3799 +discard """ +output: ''' +00000000000000000000000000000000000000000 +00000000000001111111111111110000000000000 +00000000001111111111111111111110000000000 +00000000111111111111111111111111100000000 +00000011111222222221111111111111111000000 +00000111122222222222221111111111111100000 +00001112222333333459432111111111111110000 +00011122355544344463533221111111111111000 +00111124676667556896443322211111111111100 +00111126545561919686543322221111111111100 +01111123333346967807554322222211111111110 +01111122233334455582015332222221111111110 +01111122222333344567275432222222111111110 +01111112222222334456075443222222211111110 +01111111222222233459965444332222221111110 +01111111122222223457486554433322222111110 +01111111112222222367899655543333322111110 +01111111111122222344573948465444332111110 +00111111111112222334467987727667762111100 +00111111111111122233474655557836432111100 +00011111111111112233 454433334 4321111000 +00001111111111111122354333322222211110000 +00000111111111111111222222222222111100000 +00000001111111111111111122222111110000000 +00000000111111111111111111111111100000000 +00000000000111111111111111111100000000000 +00000000000000111111111111100000000000000 +''' +""" + import macros @@ -37,9 +69,9 @@ iterator stepIt[T](start, step: T, iterations: int): T = let c = (0.36237, 0.32) -for y in stepIt(2.0, -0.0375, 107): +for y in stepIt(2.0, -0.0375 * 4, 107 div 4): var row = "" - for x in stepIt(-2.0, 0.025, 160): + for x in stepIt(-2.0, 0.025 * 4, 160 div 4): #let n = julia((x, y), c, 4.0, nmax) ### this works let n = dendriteFractal((x, y), 4.0, nmax) if n < nmax: diff --git a/tests/flags/tgenscript.nim b/tests/flags/tgenscript.nim index 45cfbfb84..989ca8bcb 100644 --- a/tests/flags/tgenscript.nim +++ b/tests/flags/tgenscript.nim @@ -1,6 +1,7 @@ discard """ file: "tgenscript.nim" target: "c" + action: compile """ echo "--genscript" diff --git a/tests/generics/t2tables.nim b/tests/generics/t2tables.nim index 3ef5e621e..e4b1fb967 100644 --- a/tests/generics/t2tables.nim +++ b/tests/generics/t2tables.nim @@ -1,3 +1,6 @@ +discard """ +action: compile +""" # bug #3669 @@ -10,4 +13,3 @@ type var g: G[string] echo g.rnodes["foo"] - diff --git a/tests/generics/tgeneric3.nim b/tests/generics/tgeneric3.nim index 6897d9de2..34b415446 100644 --- a/tests/generics/tgeneric3.nim +++ b/tests/generics/tgeneric3.nim @@ -1,3 +1,13 @@ +discard """ +output: ''' +312 +1000000 +1000000 +500000 +0 +''' +""" + import strutils type diff --git a/tests/global/tglobalforvar.nim b/tests/global/tglobalforvar.nim index af75df5c8..bc18f33f2 100644 --- a/tests/global/tglobalforvar.nim +++ b/tests/global/tglobalforvar.nim @@ -1,7 +1,9 @@ +discard """ +output: 100 +""" var funcs: seq[proc (): int {.nimcall.}] = @[] for i in 0..10: funcs.add((proc (): int = return i * i)) echo(funcs[3]()) - diff --git a/tests/init/t8314.nim b/tests/init/t8314.nim index 59d46eb33..47c8480c2 100644 --- a/tests/init/t8314.nim +++ b/tests/init/t8314.nim @@ -1,8 +1,14 @@ discard """ nimout: ''' -t8314.nim(8, 7) Hint: BEGIN [User] -t8314.nim(19, 7) Hint: END [User] +t8314.nim(14, 7) Hint: BEGIN [User] +t8314.nim(25, 7) Hint: END [User] ''' + +output: ''' +1 +1 +1 +''' """ {.hint: "BEGIN".} diff --git a/tests/iter/timplicit_auto.nim b/tests/iter/timplicit_auto.nim index d5cb95eb8..1b9f06843 100644 --- a/tests/iter/timplicit_auto.nim +++ b/tests/iter/timplicit_auto.nim @@ -15,4 +15,4 @@ iterator fields(a = (0,0), b = (h-1,w-1)): auto = yield (y,x) for y,x in fields(): - stdout.write disp[univ(x, y)] + doAssert disp[univ(x, y)] == disp[Tree] diff --git a/tests/iter/titer.nim b/tests/iter/titer.nim index c4143ae4f..22be1bad5 100644 --- a/tests/iter/titer.nim +++ b/tests/iter/titer.nim @@ -1,3 +1,16 @@ +discard """ +output: ''' +testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest2!test3?hi +what's +your +name +hi +what's +your +name +''' +""" + # Test the new iterators iterator xrange(fromm, to: int, step = 1): int = diff --git a/tests/iter/titer_no_tuple_unpack.nim b/tests/iter/titer_no_tuple_unpack.nim index 13ec11bd6..d8df10189 100644 --- a/tests/iter/titer_no_tuple_unpack.nim +++ b/tests/iter/titer_no_tuple_unpack.nim @@ -1,3 +1,18 @@ +discard """ +output: ''' +3 4 +4 5 +5 6 +6 7 +7 8 +(x: 3, y: 4) +(x: 4, y: 5) +(x: 5, y: 6) +(x: 6, y: 7) +(x: 7, y: 8) +''' +""" + iterator xrange(fromm, to: int, step = 1): tuple[x, y: int] = var a = fromm @@ -10,4 +25,3 @@ for a, b in xrange(3, 7): for tup in xrange(3, 7): echo tup - diff --git a/tests/iter/titervaropenarray.nim b/tests/iter/titervaropenarray.nim index 1e70ce247..9eea085e3 100644 --- a/tests/iter/titervaropenarray.nim +++ b/tests/iter/titervaropenarray.nim @@ -11,6 +11,3 @@ iterator iterAndZero(a: var openArray[int]): int = var x = [[1, 2, 3], [4, 5, 6]] for y in iterAndZero(x[0]): write(stdout, $y) #OUT 123 - - - diff --git a/tests/iter/tpermutations.nim b/tests/iter/tpermutations.nim index 5149eb9c2..c5067ba31 100644 --- a/tests/iter/tpermutations.nim +++ b/tests/iter/tpermutations.nim @@ -1,3 +1,14 @@ +discard """ +output: ''' +@[@[1.0, 2.0], @[3.0, 4.0]] +perm: 10.0 det: -2.0 +@[@[1.0, 2.0, 3.0, 4.0], @[4.0, 5.0, 6.0, 7.0], @[7.0, 8.0, 9.0, 10.0], @[10.0, 11.0, 12.0, 13.0]] +perm: 29556.0 det: 0.0 +@[@[0.0, 1.0, 2.0, 3.0, 4.0], @[5.0, 6.0, 7.0, 8.0, 9.0], @[10.0, 11.0, 12.0, 13.0, 14.0], @[15.0, 16.0, 17.0, 18.0, 19.0], @[20.0, 21.0, 22.0, 23.0, 24.0]] +perm: 6778800.0 det: 0.0 +''' +""" + import sequtils, sugar diff --git a/tests/iter/tshallowcopy_closures.nim b/tests/iter/tshallowcopy_closures.nim index 2f024ee7e..279e7d950 100644 --- a/tests/iter/tshallowcopy_closures.nim +++ b/tests/iter/tshallowcopy_closures.nim @@ -1,5 +1,9 @@ discard """ ccodecheck: "!@('{' \\s* 'NI HEX3Astate;' \\s* '}')" + output: ''' +a1 10 +a1 9 +''' """ # bug #1803 @@ -26,6 +30,6 @@ var z: TaskFn discard x() -z = x #shallowCopy(z, x) -z = y #shallowCopy(z, y) +shallowCopy(z, x) +shallowCopy(z, y) discard x() diff --git a/tests/iter/twrap_walkdir.nim b/tests/iter/twrap_walkdir.nim index 4ac487d8e..1d52e9791 100644 --- a/tests/iter/twrap_walkdir.nim +++ b/tests/iter/twrap_walkdir.nim @@ -1,5 +1,6 @@ - - +discard """ +action: compile +""" import os diff --git a/tests/macros/tgettype.nim b/tests/macros/tgettype.nim index fa02bce57..77a55471f 100644 --- a/tests/macros/tgettype.nim +++ b/tests/macros/tgettype.nim @@ -1,6 +1,8 @@ discard """ -msg: '''ObjectTy(Sym(Model), RecList(Sym(name), Sym(password))) -BracketExpr(Sym(typeDesc), Sym(User))''' +output: ''' +(ObjectTy (Empty) (Sym "Model") (RecList (Sym "name") (Sym "password"))) +(BracketExpr (Sym "typeDesc") (Sym "User")) +''' """ import strutils, macros diff --git a/tests/macros/tgettype2.nim b/tests/macros/tgettype2.nim index f129e6e1b..c579cf6ff 100644 --- a/tests/macros/tgettype2.nim +++ b/tests/macros/tgettype2.nim @@ -1,3 +1,35 @@ +discard """ +output: ''' +############ +#### gt #### +############ +gt(Foo): typeDesc[Foo] +gt(Bar): typeDesc[Bar] +gt(Baz): typeDesc[int] +gt(foo): distinct[int] +gt(bar): distinct[int] +gt(baz): int, int +gt(v): seq[int] +gt(vv): seq[float] +gt(t): distinct[tuple[int, int]] +gt(tt): distinct[tuple[float, float]] +gt(s): distinct[tuple[int, int]] +############# +#### gt2 #### +############# +gt2(Foo): Foo +gt2(Bar): Bar +gt2(Baz): Baz +gt2(foo): Foo +gt2(bar): Bar +gt2(baz): Baz +gt2(v): seq[int] +gt2(vv): seq[float] +gt2(t): MyType[system.int] +gt2(tt): MyType[system.float] +gt2(s): MySimpleType +''' +""" import macros, typetraits diff --git a/tests/macros/tquotedo.nim b/tests/macros/tquotedo.nim index b663b81ba..cd1f69116 100644 --- a/tests/macros/tquotedo.nim +++ b/tests/macros/tquotedo.nim @@ -1,3 +1,11 @@ +discard """ +output: ''' +123 +Hallo Welt +Hallo Welt +''' +""" + import macros macro mac(): untyped = diff --git a/tests/metatype/tmetatype_issues.nim b/tests/metatype/tmetatype_issues.nim index 5c5380c9f..c5040f9ba 100644 --- a/tests/metatype/tmetatype_issues.nim +++ b/tests/metatype/tmetatype_issues.nim @@ -1,4 +1,15 @@ - +discard """ +output:''' +void +(Field0: "string", Field1: "string") +1 mod 7 +@[2, 2, 2, 2, 2] +impl 2 called +asd +Foo +Bar +''' +""" import typetraits, macros @@ -145,6 +156,3 @@ block t3338: var t2 = Bar[int32]() t2.add() doAssert t2.x == 5 - - - diff --git a/tests/metatype/ttypedesc3.nim b/tests/metatype/ttypedesc3.nim index 3d1cf2ec9..bd973eed1 100644 --- a/tests/metatype/ttypedesc3.nim +++ b/tests/metatype/ttypedesc3.nim @@ -1,3 +1,13 @@ +discard """ +output: ''' +proc Base +proc Child +method Base +yield Base +yield Child +''' +""" + import typetraits type diff --git a/tests/misc/tendian.nim b/tests/misc/tendian.nim deleted file mode 100644 index 91044f4d5..000000000 --- a/tests/misc/tendian.nim +++ /dev/null @@ -1,3 +0,0 @@ -# test the new endian magic - -writeLine(stdout, repr(system.cpuEndian)) diff --git a/tests/misc/tgetstartmilsecs.nim b/tests/misc/tgetstartmilsecs.nim index bf508dd54..26ea856cf 100644 --- a/tests/misc/tgetstartmilsecs.nim +++ b/tests/misc/tgetstartmilsecs.nim @@ -1,7 +1,6 @@ -# import times, os var start = epochTime() os.sleep(1000) - -echo epochTime() - start #OUT 1000 +let diff = abs(epochTime() - start - 1.0) +doAssert diff < 0.005 diff --git a/tests/misc/thallo.nim b/tests/misc/thallo.nim index 17e6089ed..6f9d49121 100644 --- a/tests/misc/thallo.nim +++ b/tests/misc/thallo.nim @@ -1,4 +1,8 @@ -# Hallo +discard """ +action: compile +""" + +# noted this seems to be an old test file designed for manual testing. import os, strutils, macros diff --git a/tests/modules/t8665.nim b/tests/modules/t8665.nim index 51538df79..74d31452f 100644 --- a/tests/modules/t8665.nim +++ b/tests/modules/t8665.nim @@ -1 +1,5 @@ +discard """ + action: compile +""" + import treorder diff --git a/tests/modules/texport2.nim b/tests/modules/texport2.nim index 6e55873c5..e90c58673 100644 --- a/tests/modules/texport2.nim +++ b/tests/modules/texport2.nim @@ -1,9 +1,16 @@ +discard """ +output: ''' +abc +xyz +B.foo +''' +""" + # bug #1595, #1612 import mexport2a proc main() = - echo "Import Test, two lines should follow. One with abc and one with xyz." printAbc() printXyz() diff --git a/tests/objects/tobjcov.nim b/tests/objects/tobjcov.nim index c766adde0..817c1fcda 100644 --- a/tests/objects/tobjcov.nim +++ b/tests/objects/tobjcov.nim @@ -1,3 +1,7 @@ +discard """ +action: compile +""" + # Covariance is not type safe: type @@ -14,4 +18,3 @@ proc bp(x: var TB) = x.b[high(x.b)] = -1 var f = cast[proc (x: var TA) {.nimcall.}](bp) var a: TA f(a) # bp expects a TB, but gets a TA - diff --git a/tests/objects/tobject.nim b/tests/objects/tobject.nim index cdb8f80db..61ef7442e 100644 --- a/tests/objects/tobject.nim +++ b/tests/objects/tobject.nim @@ -1,3 +1,7 @@ +discard """ +output: "[Suite] object basic methods" +""" + import unittest type Obj = object diff --git a/tests/parallel/tarray_of_channels.nim b/tests/parallel/tarray_of_channels.nim index 90ae8369c..e2a682bd5 100644 --- a/tests/parallel/tarray_of_channels.nim +++ b/tests/parallel/tarray_of_channels.nim @@ -1,3 +1,15 @@ +discard """ +sortoutput: true +output: ''' +(x: 0.0) +(x: 0.0) +(x: 0.0) +test +test +test +''' +""" + # bug #2257 import threadpool diff --git a/tests/parallel/tdont_be_stupid.nim b/tests/parallel/tdont_be_stupid.nim index a7e82466a..49f80ae8b 100644 --- a/tests/parallel/tdont_be_stupid.nim +++ b/tests/parallel/tdont_be_stupid.nim @@ -1,3 +1,11 @@ +discard """ +output: ''' +3 +25 +40 +50 +''' +""" import threadpool, os diff --git a/tests/parallel/tguard1.nim b/tests/parallel/tguard1.nim index c7972d225..b1eb7e7c5 100644 --- a/tests/parallel/tguard1.nim +++ b/tests/parallel/tguard1.nim @@ -1,3 +1,7 @@ +discard """ +output: "90" +""" + when false: template lock(a, b: ptr Lock; body: stmt) = diff --git a/tests/parallel/tlet_spawn.nim b/tests/parallel/tlet_spawn.nim index 463ee1a47..62341d8f0 100644 --- a/tests/parallel/tlet_spawn.nim +++ b/tests/parallel/tlet_spawn.nim @@ -1,3 +1,8 @@ +discard """ +output: ''' +done999 999 +''' +""" import threadpool diff --git a/tests/parallel/tmissing_deepcopy.nim b/tests/parallel/tmissing_deepcopy.nim index 53481e4df..e540775f8 100644 --- a/tests/parallel/tmissing_deepcopy.nim +++ b/tests/parallel/tmissing_deepcopy.nim @@ -1,5 +1,6 @@ discard """ ccodeCheck: "\\i @'deepCopy(' .*" + action: compile """ # bug #2286 diff --git a/tests/parallel/tsimple_array_checks.nim b/tests/parallel/tsimple_array_checks.nim index 9874d3299..380611374 100644 --- a/tests/parallel/tsimple_array_checks.nim +++ b/tests/parallel/tsimple_array_checks.nim @@ -1,3 +1,24 @@ +discard """ +output: ''' +Hello 1 +Hello 2 +Hello 3 +Hello 4 +Hello 5 +Hello 6 +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +''' +""" + # bug #2287 import threadPool diff --git a/tests/pragmas/tnoreturn.nim b/tests/pragmas/tnoreturn.nim index 50b427d71..6d0466df3 100644 --- a/tests/pragmas/tnoreturn.nim +++ b/tests/pragmas/tnoreturn.nim @@ -1,5 +1,6 @@ discard """ ccodeCheck: "\\i @'__attribute__((noreturn))' .*" +action: compile """ proc noret1*(i: int) {.noreturn.} = diff --git a/tests/system/tparams.nim b/tests/system/tparams.nim index dd5511b8f..015530043 100644 --- a/tests/system/tparams.nim +++ b/tests/system/tparams.nim @@ -1,6 +1,3 @@ -discard """ -""" - import os import osproc import parseopt2 @@ -13,7 +10,6 @@ if argv == @[]: doAssert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar=a --a=c:d --ab -c --a[baz]:doo") == 0 else: let f = toSeq(getopt()) - echo f.repr doAssert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == "" doAssert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a" doAssert f[2].kind == cmdLongOption and f[2].key == "a=c" and f[2].val == "d" diff --git a/tests/types/tauto_canbe_void.nim b/tests/types/tauto_canbe_void.nim index b071c08e1..c43215d1e 100644 --- a/tests/types/tauto_canbe_void.nim +++ b/tests/types/tauto_canbe_void.nim @@ -1,3 +1,10 @@ +discard """ +output: ''' +arg +arg +''' +""" + import sugar @@ -6,4 +13,3 @@ template tempo(s) = tempo((s: string)->auto => echo(s)) tempo((s: string) => echo(s)) - diff --git a/tests/vm/tgorge.sh b/tests/vm/tgorge.sh index ba47afeae..ba47afeae 100644..100755 --- a/tests/vm/tgorge.sh +++ b/tests/vm/tgorge.sh diff --git a/tests/vm/tgorgeex.sh b/tests/vm/tgorgeex.sh index 36ba0a02f..36ba0a02f 100644..100755 --- a/tests/vm/tgorgeex.sh +++ b/tests/vm/tgorgeex.sh |