diff options
Diffstat (limited to 'tests')
134 files changed, 913 insertions, 179 deletions
diff --git a/tests/accept/run/spec.csv b/tests/accept/run/spec.csv deleted file mode 100755 index 5102c85b1..000000000 --- a/tests/accept/run/spec.csv +++ /dev/null @@ -1,89 +0,0 @@ -tack.nim;125 -tambsym2.nim;7 -tambsys.nim; -tarray.nim;10012 -tarraycons.nim;6 -tarray2.nim;[16, 25, 36] -tarray3.nim;3 -tassert.nim;assertion failure!this shall be always written -tbind1.nim;3 -tbind3.nim;1 -tbintre2.nim;helloworld99110223 -tbintree.nim;helloworld99110223 -tbug499771.nim;TSubRange: 5 from 1 to 10 -tbug511622.nim;3 -tcasestm.nim;ayyy -tcgbug.nim; -tclosure.nim;2 4 6 8 10 -tcnstseq.nim;AngelikaAnneAnnaAnkaAnja -tconstr2.nim;69 -tcontinuexc.nim;ECcaught -tcopy.nim;TEMP=C:\Programs\xyz\bin -tcountup.nim;0123456789 -tcurrncy.nim;25 -temit.nim;509 -tenumhole.nim;my value A1my value Bconc2valueCabc4abc -texcsub.nim;caught! -texplicitgeneric1.nim;Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13 -tfinally.nim;came here 3 -tfinally2.nim;ABCD -tfinally3.nim;false -tfloat1.nim;Error: unhandled exception: FPU operation caused an overflow [EFloatOverflow] -tfloat2.nim;Error: unhandled exception: FPU operation caused a NaN result [EFloatInvalidOp] -tfloat3.nim;Nimrod 3.4368930843, 0.3299290698 C double: 3.4368930843, 0.3299290698 -tformat.nim;Hi Andreas! How do you feel, Rumpf? -thintoff.nim;0 -tinit.nim;Hello from module! Hello from main module! -tints.nim;Success -tisopr.nim;falsetrue -titer2.nim;123 -titer3.nim;1231 -titer5.nim;abcxyz -titer6.nim;000 -tlenopenarray.nim;1 -tlowhigh.nim;10 -tmatrix.nim;111 -tmultim1.nim;7 -tmultim2.nim;collide: unit, thing collide: unit, thing collide: thing, unit -tmultim3.nim;Hi derived! -tmultim4.nim;hello -tnamedenumfields.nim;my value A0my value Bconc1valueCabc3abc -tnestif.nim;i == 2 -tnestprc.nim;10 -toop1.nim;34[]o 5 -topenarrayrepr.nim;5 - [1] -topenlen.nim;7 -toprprec.nim;done -toverflw.nim;the computation overflowed -toverflw2.nim;Error: unhandled exception: over- or underflow [EOverflow] -toverl2.nim;true012 -toverlop.nim;3 -toverwr.nim;hello -tovfint.nim;works! -tpos.nim;6 -tprintf.nim;Andreas Rumpf -tprocvar.nim;papbpcpdpe7 -tquotewords.nim;thisanexample -tregex.nim;key: keyAYes! -treguse.nim;055this should be the casehugh -treraise.nim;Error: unhandled exception: bla [ESomeOtherErr] -tromans.nim;success -tseqcon.nim;Hithere, what's your name?Hathere, what's your name? -tseqtuple.nim;fA13msg1falsefB14msg2truefC15msg3false -tsets.nim;Ha ein F ist in s! -tsidee2.nim;5 -tsidee3.nim;5 -tsimmeth.nim;HELLO WORLD! -tsplit.nim;true -tstrange.nim;hallo4 -tstrlits.nim;a""long string"""""abc"def -tstrutil.nim;ha/home/a1xyz/usr/bin -tvardecl.nim;44 -tvariantasgn.nim;came here -tvariantstack.nim;came here -tvarnums.nim;Success! -tvartup.nim;2 3 -tunhandledexc.nim;Error: unhandled exception: bla [ESomeOtherErr] -twrongexc.nim;Error: unhandled exception [EInvalidValue] -txmlgen.nim;<h1><a href="http://force7.de/nimrod">Nimrod</a></h1> -txmltree.nim;true diff --git a/tests/accept/run/tack.nim b/tests/accept/run/tack.nim index 59535e547..680ff567e 100755 --- a/tests/accept/run/tack.nim +++ b/tests/accept/run/tack.nim @@ -1,3 +1,7 @@ +discard """ + file: "tack.nim" + output: "125" +""" # the Ackermann function proc ack(x, y: int): int = @@ -13,3 +17,5 @@ proc ack(x, y: int): int = # echo(ack(0, 0)) write(stdout, ack(3, 4)) #OUT 125 + + diff --git a/tests/accept/run/tambsym2.nim b/tests/accept/run/tambsym2.nim index 9178182aa..745427c54 100755 --- a/tests/accept/run/tambsym2.nim +++ b/tests/accept/run/tambsym2.nim @@ -1,3 +1,7 @@ +discard """ + file: "tambsym2.nim" + output: "7" +""" # Test overloading of procs with locals type @@ -16,3 +20,5 @@ m.len = 7 m.data = "1234" x(m, 5) #OUT 7 + + diff --git a/tests/accept/run/tambsys.nim b/tests/accept/run/tambsys.nim index bb2622824..a88615866 100755 --- a/tests/accept/run/tambsys.nim +++ b/tests/accept/run/tambsys.nim @@ -1,3 +1,7 @@ +discard """ + file: "tambsys.nim" + output: "" +""" # Test ambiguous symbols import mambsys1, mambsys2 @@ -5,3 +9,5 @@ import mambsys1, mambsys2 var v: mambsys1.TExport mambsys2.foo(3) #OUT + + diff --git a/tests/accept/run/tarray.nim b/tests/accept/run/tarray.nim index 252cbd991..16ef558d1 100755 --- a/tests/accept/run/tarray.nim +++ b/tests/accept/run/tarray.nim @@ -1,3 +1,7 @@ +discard """ + file: "tarray.nim" + output: "10012" +""" # simple check for one dimensional arrays type @@ -25,3 +29,5 @@ write(stdout, sum([1, 2, 3, 4])) write(stdout, sum([])) write(stdout, getPos( (x: 5, y: 7) )) #OUT 10012 + + diff --git a/tests/accept/run/tarray2.nim b/tests/accept/run/tarray2.nim index eb0b75692..048f51795 100755 --- a/tests/accept/run/tarray2.nim +++ b/tests/accept/run/tarray2.nim @@ -1,3 +1,7 @@ +discard """ + file: "tarray2.nim" + output: "[16, 25, 36]" +""" # simple check for one dimensional arrays type @@ -16,3 +20,5 @@ y = x echo repr(mul(x, y)) #OUT [16, 25, 36] + + diff --git a/tests/accept/run/tarray3.nim b/tests/accept/run/tarray3.nim index 881bb7ba4..d28778357 100755 --- a/tests/accept/run/tarray3.nim +++ b/tests/accept/run/tarray3.nim @@ -1,3 +1,7 @@ +discard """ + file: "tarray3.nim" + output: "3" +""" # simple check for two dimensional arrays const @@ -5,3 +9,5 @@ const echo myData[0][2] #OUT 3 + + diff --git a/tests/accept/run/tarraycons.nim b/tests/accept/run/tarraycons.nim index 12f13ac33..0b2a42c2f 100755 --- a/tests/accept/run/tarraycons.nim +++ b/tests/accept/run/tarraycons.nim @@ -1,3 +1,7 @@ +discard """ + file: "tarraycons.nim" + output: "6" +""" type TEnum = enum @@ -15,3 +19,5 @@ const echo myMapping[eC][1] + + diff --git a/tests/accept/run/tassert.nim b/tests/accept/run/tassert.nim index 9fd18e9bd..e32ee0a84 100755 --- a/tests/accept/run/tassert.nim +++ b/tests/accept/run/tassert.nim @@ -1,3 +1,7 @@ +discard """ + file: "tassert.nim" + output: "assertion failure!this shall be always written" +""" # test assert and exception handling proc callB() = assert(False) @@ -14,3 +18,5 @@ finally: system.write(stdout, "this shall be always written") assert(false) #OUT assertion failure!this shall be always written + + diff --git a/tests/accept/run/tbind1.nim b/tests/accept/run/tbind1.nim index e7eed3e4f..536a67f91 100755 --- a/tests/accept/run/tbind1.nim +++ b/tests/accept/run/tbind1.nim @@ -1,3 +1,7 @@ +discard """ + file: "tbind1.nim" + output: "3" +""" # Test the new ``bind`` keyword for templates proc p1(x: int8, y: int): int = return x + y @@ -12,3 +16,5 @@ proc p1(x: int, y: int8): int = return x - y echo tempBind(1'i8, 2'i8) #OUT 3 + + diff --git a/tests/accept/run/tbind3.nim b/tests/accept/run/tbind3.nim index f7fb4865b..551acc10f 100755 --- a/tests/accept/run/tbind3.nim +++ b/tests/accept/run/tbind3.nim @@ -1,5 +1,11 @@ +discard """ + file: "tbind3.nim" + output: "1" +""" # Module B import mbind3 echo genId() #OUT 1 + + diff --git a/tests/accept/run/tbintre2.nim b/tests/accept/run/tbintre2.nim index e85837dfa..2a7225411 100755 --- a/tests/accept/run/tbintre2.nim +++ b/tests/accept/run/tbintre2.nim @@ -1,3 +1,7 @@ +discard """ + file: "tbintre2.nim" + output: "helloworld99110223" +""" # Same test, but check module boundaries import tbintree @@ -23,3 +27,5 @@ for y in items(r2): #OUT helloworld99110223 + + diff --git a/tests/accept/run/tbintree.nim b/tests/accept/run/tbintree.nim index 0561e004a..8cc8acb82 100755 --- a/tests/accept/run/tbintree.nim +++ b/tests/accept/run/tbintree.nim @@ -1,3 +1,7 @@ +discard """ + file: "tbintree.nim" + output: "helloworld99110223" +""" type TBinaryTree[T] = object # TBinaryTree is a generic type with # with generic param ``T`` @@ -99,3 +103,5 @@ when isMainModule: stdout.write(y) #OUT helloworld99110223 + + diff --git a/tests/accept/run/tbug499771.nim b/tests/accept/run/tbug499771.nim index 1b141adac..633ab39f6 100755 --- a/tests/accept/run/tbug499771.nim +++ b/tests/accept/run/tbug499771.nim @@ -1,6 +1,12 @@ +discard """ + file: "tbug499771.nim" + output: "TSubRange: 5 from 1 to 10" +""" type TSubRange = range[1 .. 10] var sr: TSubRange = 5 echo("TSubRange: " & $sr & " from " & $low(TSubRange) & " to " & $high(TSubRange)) + + diff --git a/tests/accept/run/tbug511622.nim b/tests/accept/run/tbug511622.nim index c0a2555f4..a5360423d 100755 --- a/tests/accept/run/tbug511622.nim +++ b/tests/accept/run/tbug511622.nim @@ -1,3 +1,7 @@ +discard """ + file: "tbug511622.nim" + output: "3" +""" import StrUtils, Math proc FibonacciA(n: int): int64 = @@ -8,3 +12,5 @@ proc FibonacciA(n: int): int64 = echo FibonacciA(4) #OUT 3 + + diff --git a/tests/accept/run/tcasestm.nim b/tests/accept/run/tcasestm.nim index 277b0bab1..cb63e0c51 100755 --- a/tests/accept/run/tcasestm.nim +++ b/tests/accept/run/tcasestm.nim @@ -1,3 +1,7 @@ +discard """ + file: "tcasestm.nim" + output: "ayyy" +""" # Test the case statement type @@ -30,3 +34,5 @@ else: #OUT ayyy + + diff --git a/tests/accept/run/tcgbug.nim b/tests/accept/run/tcgbug.nim index 320821fb6..aa0f0fa6b 100755 --- a/tests/accept/run/tcgbug.nim +++ b/tests/accept/run/tcgbug.nim @@ -1,3 +1,7 @@ +discard """ + file: "tcgbug.nim" + output: "" +""" type TObj = object @@ -15,3 +19,5 @@ var new(a) q(a) + + diff --git a/tests/accept/run/tclosure.nim b/tests/accept/run/tclosure.nim index 761e9a8f3..28a51e1ac 100755 --- a/tests/accept/run/tclosure.nim +++ b/tests/accept/run/tclosure.nim @@ -1,3 +1,7 @@ +discard """ + file: "tclosure.nim" + output: "2 4 6 8 10" +""" # Test the closure implementation proc map(n: var openarray[int], fn: proc (x: int): int {.closure}) = @@ -24,3 +28,5 @@ for x in items(myData): #OUT 2 4 6 8 10 + + diff --git a/tests/accept/run/tcnstseq.nim b/tests/accept/run/tcnstseq.nim index 4f389bb3b..e7d2333b4 100755 --- a/tests/accept/run/tcnstseq.nim +++ b/tests/accept/run/tcnstseq.nim @@ -1,3 +1,7 @@ +discard """ + file: "tcnstseq.nim" + output: "AngelikaAnneAnnaAnkaAnja" +""" # Test the new implicit conversion from sequences to arrays in a constant # context. @@ -9,3 +13,5 @@ const for x in items(myWords): write(stdout, x) #OUT AngelikaAnneAnnaAnkaAnja + + diff --git a/tests/accept/run/tconstr2.nim b/tests/accept/run/tconstr2.nim index 7687a416c..30cec5cb8 100755 --- a/tests/accept/run/tconstr2.nim +++ b/tests/accept/run/tconstr2.nim @@ -1,3 +1,7 @@ +discard """ + file: "tconstr2.nim" + output: "69" +""" # Test array, record constructors type @@ -18,3 +22,5 @@ const write(stdout, things[0].x) #OUT 69 + + diff --git a/tests/accept/run/tcontinuexc.nim b/tests/accept/run/tcontinuexc.nim index 496ee8164..c43e68c93 100755 --- a/tests/accept/run/tcontinuexc.nim +++ b/tests/accept/run/tcontinuexc.nim @@ -1,3 +1,7 @@ +discard """ + file: "tcontinuexc.nim" + output: "ECcaught" +""" type ESomething = object of E_Base ESomeOtherErr = object of E_Base @@ -21,3 +25,5 @@ finally: #OUT ECcaught + + diff --git a/tests/accept/run/tcopy.nim b/tests/accept/run/tcopy.nim index 6cb2ec14c..3c7ccae4b 100755 --- a/tests/accept/run/tcopy.nim +++ b/tests/accept/run/tcopy.nim @@ -1,3 +1,7 @@ +discard """ + file: "tcopy.nim" + output: "TEMP=C:\\Programs\\xyz\\bin" +""" # tests the copy proc import @@ -17,3 +21,5 @@ proc main() = main() #OUT TEMP=C:\Programs\xyz\bin + + diff --git a/tests/accept/run/tcountup.nim b/tests/accept/run/tcountup.nim index 4d4c9b304..e68a614b0 100755 --- a/tests/accept/run/tcountup.nim +++ b/tests/accept/run/tcountup.nim @@ -1,3 +1,7 @@ +discard """ + file: "tcountup.nim" + output: "0123456789" +""" # Test new countup and unary < @@ -6,3 +10,5 @@ for i in 0 .. < 10'i64: #OUT 0123456789 + + diff --git a/tests/accept/run/tcurrncy.nim b/tests/accept/run/tcurrncy.nim index fa08d620b..a614de7af 100755 --- a/tests/accept/run/tcurrncy.nim +++ b/tests/accept/run/tcurrncy.nim @@ -1,3 +1,7 @@ +discard """ + file: "tcurrncy.nim" + output: "25" +""" template Additive(typ: typeDesc): stmt = proc `+` *(x, y: typ): typ {.borrow.} proc `-` *(x, y: typ): typ {.borrow.} @@ -30,3 +34,5 @@ DefineCurrency(TDollar, int) DefineCurrency(TEuro, int) echo($( 12.TDollar + 13.TDollar )) #OUT 25 + + diff --git a/tests/accept/run/temit.nim b/tests/accept/run/temit.nim index 81f9b53ae..cb7d513bd 100755 --- a/tests/accept/run/temit.nim +++ b/tests/accept/run/temit.nim @@ -1,3 +1,7 @@ +discard """ + file: "temit.nim" + output: "509" +""" # Test the new ``emit`` pragma: {.emit: """ @@ -12,3 +16,5 @@ proc embedsC() {.pure.} = embedsC() + + diff --git a/tests/accept/run/tenumhole.nim b/tests/accept/run/tenumhole.nim index 75fb74592..b721c73dd 100755 --- a/tests/accept/run/tenumhole.nim +++ b/tests/accept/run/tenumhole.nim @@ -1,3 +1,7 @@ +discard """ + file: "tenumhole.nim" + output: "my value A1my value Bconc2valueCabc4abc" +""" const strValB = "my value B" @@ -14,3 +18,5 @@ var x = valueD echo valueA, ord(valueA), valueB, ord(valueB), valueC, valueD, ord(valueD), x + + diff --git a/tests/accept/run/texcsub.nim b/tests/accept/run/texcsub.nim index b35f0fa3f..3dba357f9 100755 --- a/tests/accept/run/texcsub.nim +++ b/tests/accept/run/texcsub.nim @@ -1,3 +1,7 @@ +discard """ + file: "texcsub.nim" + output: "caught!" +""" # Test inheritance for exception matching: try: @@ -9,3 +13,5 @@ except: #OUT caught! + + diff --git a/tests/accept/run/texplicitgeneric1.nim b/tests/accept/run/texplicitgeneric1.nim index 54fff5246..6cca71ac0 100755 --- a/tests/accept/run/texplicitgeneric1.nim +++ b/tests/accept/run/texplicitgeneric1.nim @@ -1,3 +1,7 @@ +discard """ + file: "texplicitgeneric1.nim" + output: "Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13" +""" # test explicit type instantiation type @@ -30,3 +34,5 @@ c.add('B', "13") for k, v in items(c): stdout.write(" Key: ", $k, " value: ", v) + + diff --git a/tests/accept/run/texplicitgeneric2.nim b/tests/accept/run/texplicitgeneric2.nim index 9bd2f04c8..f2e628223 100755 --- a/tests/accept/run/texplicitgeneric2.nim +++ b/tests/accept/run/texplicitgeneric2.nim @@ -1,3 +1,7 @@ +discard """ + output: "Key: 12 value: 12Key: 13 value: 13 Key: A value: 12 Key: B value: 13" +""" + # test explicit type instantiation type diff --git a/tests/accept/run/tfinally.nim b/tests/accept/run/tfinally.nim index 92c1e500f..29313c3fd 100755 --- a/tests/accept/run/tfinally.nim +++ b/tests/accept/run/tfinally.nim @@ -1,3 +1,7 @@ +discard """ + file: "tfinally.nim" + output: "came here 3" +""" # Test return in try statement: proc main: int = @@ -13,3 +17,5 @@ proc main: int = echo main() #OUT came here 3 + + diff --git a/tests/accept/run/tfinally2.nim b/tests/accept/run/tfinally2.nim index 10d08e816..3ed212a7c 100755 --- a/tests/accept/run/tfinally2.nim +++ b/tests/accept/run/tfinally2.nim @@ -1,3 +1,7 @@ +discard """ + file: "tfinally2.nim" + output: "ABCD" +""" # Test break in try statement: proc main: int = @@ -19,3 +23,5 @@ proc main: int = discard main() #OUT ABCD + + diff --git a/tests/accept/run/tfinally3.nim b/tests/accept/run/tfinally3.nim index e8d81c893..e65661cd0 100755 --- a/tests/accept/run/tfinally3.nim +++ b/tests/accept/run/tfinally3.nim @@ -1,3 +1,7 @@ +discard """ + file: "tfinally3.nim" + output: "false" +""" # Test break in try statement: proc main: bool = @@ -10,3 +14,5 @@ proc main: bool = echo main() #OUT false + + diff --git a/tests/accept/run/tfloat1.nim b/tests/accept/run/tfloat1.nim index 89911dd61..3826bf1f5 100755 --- a/tests/accept/run/tfloat1.nim +++ b/tests/accept/run/tfloat1.nim @@ -1,3 +1,7 @@ +discard """ + file: "tfloat1.nim" + output: "Error: unhandled exception: FPU operation caused an overflow [EFloatOverflow]" +""" # Test new floating point exceptions {.floatChecks: on.} @@ -6,3 +10,5 @@ var x = 0.8 var y = 0.0 echo x / y #OUT Error: unhandled exception: FPU operation caused an overflow [EFloatOverflow] + + diff --git a/tests/accept/run/tfloat2.nim b/tests/accept/run/tfloat2.nim index 92421d446..e7a9ce76f 100755 --- a/tests/accept/run/tfloat2.nim +++ b/tests/accept/run/tfloat2.nim @@ -1,3 +1,7 @@ +discard """ + file: "tfloat2.nim" + output: "Error: unhandled exception: FPU operation caused a NaN result [EFloatInvalidOp]" +""" # Test new floating point exceptions {.floatChecks: on.} @@ -6,3 +10,5 @@ var x = 0.0 var y = 0.0 echo x / y #OUT Error: unhandled exception: FPU operation caused a NaN result [EFloatInvalidOp] + + diff --git a/tests/accept/run/tfloat3.nim b/tests/accept/run/tfloat3.nim index 72acce958..4382dd3ed 100755 --- a/tests/accept/run/tfloat3.nim +++ b/tests/accept/run/tfloat3.nim @@ -1,3 +1,7 @@ +discard """ + file: "tfloat3.nim" + output: "Nimrod 3.4368930843, 0.3299290698 C double: 3.4368930843, 0.3299290698" +""" import math, strutils @@ -16,3 +20,5 @@ var x: float = 1.234567890123456789 c_printf("Nimrod %.10f, %.10f ", exp(x), cos(x)) printFloats() + + diff --git a/tests/accept/run/tformat.nim b/tests/accept/run/tformat.nim index aba35504b..92c0c16f5 100755 --- a/tests/accept/run/tformat.nim +++ b/tests/accept/run/tformat.nim @@ -1,6 +1,12 @@ +discard """ + file: "tformat.nim" + output: "Hi Andreas! How do you feel, Rumpf?" +""" # Tests the new format proc (including the & and &= operators) import strutils echo("Hi $1! How do you feel, $2?\n" % ["Andreas", "Rumpf"]) #OUT Hi Andreas! How do you feel, Rumpf? + + diff --git a/tests/accept/run/thintoff.nim b/tests/accept/run/thintoff.nim index 7aff283d6..807ff44f3 100755 --- a/tests/accept/run/thintoff.nim +++ b/tests/accept/run/thintoff.nim @@ -1,6 +1,12 @@ +discard """ + file: "thintoff.nim" + output: "0" +""" {.hint[XDeclaredButNotUsed]: off.} var x: int echo x #OUT 0 + + diff --git a/tests/accept/run/tinit.nim b/tests/accept/run/tinit.nim index 386bfec37..5c75567ec 100755 --- a/tests/accept/run/tinit.nim +++ b/tests/accept/run/tinit.nim @@ -1,6 +1,12 @@ +discard """ + file: "tinit.nim" + output: "Hello from module! Hello from main module!" +""" # Test the new init section in modules import minit write(stdout, "Hello from main module!\n") #OUT Hello from module! Hello from main module! + + diff --git a/tests/accept/run/tints.nim b/tests/accept/run/tints.nim index f2b52c134..6c9897860 100755 --- a/tests/accept/run/tints.nim +++ b/tests/accept/run/tints.nim @@ -1,3 +1,7 @@ +discard """ + file: "tints.nim" + output: "Success" +""" # Test the different integer operations var testNumber = 0 @@ -39,3 +43,5 @@ test(`shl`, 0xffffffff'i32, 0x4'i32, 0xfffffff0'i32) Echo("Success") #OUT Success + + diff --git a/tests/accept/run/tisopr.nim b/tests/accept/run/tisopr.nim index d52859b09..7e7a8f650 100755 --- a/tests/accept/run/tisopr.nim +++ b/tests/accept/run/tisopr.nim @@ -1,3 +1,7 @@ +discard """ + file: "tisopr.nim" + output: "falsetrue" +""" # Test is operator type @@ -18,3 +22,5 @@ write(stdout, p(m)) write(stdout, p(n)) #OUT falsetrue + + diff --git a/tests/accept/run/titer2.nim b/tests/accept/run/titer2.nim index b9cdb53fe..1e70ce247 100755 --- a/tests/accept/run/titer2.nim +++ b/tests/accept/run/titer2.nim @@ -1,3 +1,7 @@ +discard """ + file: "titer2.nim" + output: "123" +""" # Try to break the transformation pass: iterator iterAndZero(a: var openArray[int]): int = for i in 0..len(a)-1: @@ -8,3 +12,5 @@ var x = [[1, 2, 3], [4, 5, 6]] for y in iterAndZero(x[0]): write(stdout, $y) #OUT 123 + + diff --git a/tests/accept/run/titer3.nim b/tests/accept/run/titer3.nim index d0e121445..ab95dd7bd 100755 --- a/tests/accept/run/titer3.nim +++ b/tests/accept/run/titer3.nim @@ -1,3 +1,7 @@ +discard """ + file: "titer3.nim" + output: "1231" +""" iterator count1_3: int = yield 1 @@ -14,4 +18,5 @@ iterator iter1(a: openArray[int]): int = var x = [[1, 2, 3], [4, 5, 6]] for y in iter1(x[0]): write(stdout, $y) -#OUT 1231 \ No newline at end of file +#OUT 1231 + diff --git a/tests/accept/run/titer5.nim b/tests/accept/run/titer5.nim index 1ac37ba66..bbd50fcb1 100755 --- a/tests/accept/run/titer5.nim +++ b/tests/accept/run/titer5.nim @@ -1,3 +1,7 @@ +discard """ + file: "titer5.nim" + output: "abcxyz" +""" # Test method call syntax for iterators: import strutils @@ -8,3 +12,5 @@ for x in lines.split(): #OUT abcxyz + + diff --git a/tests/accept/run/titer6.nim b/tests/accept/run/titer6.nim index 8a1d9cf1b..fa58e9a6c 100755 --- a/tests/accept/run/titer6.nim +++ b/tests/accept/run/titer6.nim @@ -1,3 +1,7 @@ +discard """ + file: "titer6.nim" + output: "000" +""" # Test iterator with more than 1 yield statement import strutils @@ -29,3 +33,5 @@ proc wordWrap2(s: string, maxLineWidth = 80, for word, isSep in tokenize2(s, seps): var w = 0 + + diff --git a/tests/accept/run/tlenopenarray.nim b/tests/accept/run/tlenopenarray.nim index 9731cb4f2..58041def2 100755 --- a/tests/accept/run/tlenopenarray.nim +++ b/tests/accept/run/tlenopenarray.nim @@ -1,5 +1,11 @@ +discard """ + file: "tlenopenarray.nim" + output: "1" +""" # len(x) --> len([x]) --> match! echo len(1_000_000) #OUT 1 + + diff --git a/tests/accept/run/tlowhigh.nim b/tests/accept/run/tlowhigh.nim index 79f5c5b95..d1cbd3272 100755 --- a/tests/accept/run/tlowhigh.nim +++ b/tests/accept/run/tlowhigh.nim @@ -1,3 +1,7 @@ +discard """ + file: "tlowhigh.nim" + output: "10" +""" # Test the magic low() and high() procs type @@ -16,3 +20,5 @@ proc sum(a: openarray[int]): int = write(stdout, sum([1, 2, 3, 4])) #OUT 10 + + diff --git a/tests/accept/run/tmatrix.nim b/tests/accept/run/tmatrix.nim index a162d0f10..1dd09291b 100755 --- a/tests/accept/run/tmatrix.nim +++ b/tests/accept/run/tmatrix.nim @@ -1,3 +1,7 @@ +discard """ + file: "tmatrix.nim" + output: "111" +""" # Test overloading of [] with multiple indices type @@ -58,3 +62,5 @@ for i in 0..w-1: for i in 0..w-1: stdout.write(m[i,i]) #OUT 111 + + diff --git a/tests/accept/run/tmultim1.nim b/tests/accept/run/tmultim1.nim index 5d807e4c9..542c846c7 100755 --- a/tests/accept/run/tmultim1.nim +++ b/tests/accept/run/tmultim1.nim @@ -1,3 +1,7 @@ +discard """ + file: "tmultim1.nim" + output: "7" +""" # Test multi methods type @@ -21,3 +25,5 @@ proc newPlus(a, b: ref TExpr): ref TPlusExpr = result.b = b echo eval(newPlus(newPlus(newLit(1), newLit(2)), newLit(4))) #OUT 7 + + diff --git a/tests/accept/run/tmultim2.nim b/tests/accept/run/tmultim2.nim index c43c9b6f0..956b22647 100755 --- a/tests/accept/run/tmultim2.nim +++ b/tests/accept/run/tmultim2.nim @@ -1,3 +1,7 @@ +discard """ + file: "tmultim2.nim" + output: "collide: unit, thing collide: unit, thing collide: thing, unit" +""" # Test multi methods type @@ -28,3 +32,5 @@ collide(a, b) #OUT collide: unit, thing collide: unit, thing collide: thing, unit + + diff --git a/tests/accept/run/tmultim3.nim b/tests/accept/run/tmultim3.nim index a3271d8d9..373c84c0e 100755 --- a/tests/accept/run/tmultim3.nim +++ b/tests/accept/run/tmultim3.nim @@ -1,3 +1,7 @@ +discard """ + file: "tmultim3.nim" + output: "Hi derived!" +""" import mmultim3 type @@ -12,3 +16,5 @@ new(a) myObj = a testMyObj() + + diff --git a/tests/accept/run/tmultim4.nim b/tests/accept/run/tmultim4.nim index fbfaf3175..6bb7970dd 100755 --- a/tests/accept/run/tmultim4.nim +++ b/tests/accept/run/tmultim4.nim @@ -1,3 +1,7 @@ +discard """ + file: "tmultim4.nim" + output: "hello" +""" type Test = object of TObject @@ -37,3 +41,5 @@ for z in 1..4: # break + + diff --git a/tests/accept/run/tnamedenumfields.nim b/tests/accept/run/tnamedenumfields.nim index 6012cf1eb..e9ac88a42 100755 --- a/tests/accept/run/tnamedenumfields.nim +++ b/tests/accept/run/tnamedenumfields.nim @@ -1,3 +1,7 @@ +discard """ + file: "tnamedenumfields.nim" + output: "my value A0my value Bconc1valueCabc3abc" +""" const strValB = "my value B" @@ -15,3 +19,5 @@ var x = valueD echo valueA, ord(valueA), valueB, ord(valueB), valueC, valueD, ord(valueD), x + + diff --git a/tests/accept/run/tnestif.nim b/tests/accept/run/tnestif.nim index 558fe8d07..bfcd8751c 100755 --- a/tests/accept/run/tnestif.nim +++ b/tests/accept/run/tnestif.nim @@ -1,3 +1,7 @@ +discard """ + file: "tnestif.nim" + output: "i == 2" +""" # test nested ifs var @@ -16,3 +20,5 @@ elif x == 2: else: write(stdout, "looks like Python") #OUT i == 2 + + diff --git a/tests/accept/run/tnestprc.nim b/tests/accept/run/tnestprc.nim index b7326e032..c10ad6abf 100755 --- a/tests/accept/run/tnestprc.nim +++ b/tests/accept/run/tnestprc.nim @@ -1,3 +1,7 @@ +discard """ + file: "tnestprc.nim" + output: "10" +""" # Test nested procs without closures proc Add3(x: int): int = @@ -8,3 +12,5 @@ proc Add3(x: int): int = echo Add3(7) #OUT 10 + + diff --git a/tests/accept/run/toop1.nim b/tests/accept/run/toop1.nim index 8bae002e7..a925642e8 100755 --- a/tests/accept/run/toop1.nim +++ b/tests/accept/run/toop1.nim @@ -1,3 +1,7 @@ +discard """ + file: "toop1.nim" + output: "34[]o 5" +""" # Test the stuff in the tutorial import macros @@ -80,3 +84,5 @@ c!draw() #OUT 34[]o 5 + + diff --git a/tests/accept/run/topenarrayrepr.nim b/tests/accept/run/topenarrayrepr.nim index 7e976540f..ec7be722a 100755 --- a/tests/accept/run/topenarrayrepr.nim +++ b/tests/accept/run/topenarrayrepr.nim @@ -1,3 +1,7 @@ +discard """ + file: "topenarrayrepr.nim" + output: "5 - [1]" +""" type TProc = proc (n: int, m: openarray[int64]) @@ -9,3 +13,5 @@ proc Bar(n: int, m: openarray[int64]) = Foo(5, Bar) #OUT 5 - [1] + + diff --git a/tests/accept/run/topenlen.nim b/tests/accept/run/topenlen.nim index b9d7fbc2d..fec8e87b7 100755 --- a/tests/accept/run/topenlen.nim +++ b/tests/accept/run/topenlen.nim @@ -1,3 +1,7 @@ +discard """ + file: "topenlen.nim" + output: "7" +""" # Tests a special bug proc choose(b: openArray[string]): string = return b[0] @@ -10,3 +14,5 @@ proc p(a, b: openarray[string]): int = discard choose(["sh", "-c", $p([""], ["a"])]) echo($p(["", "ha", "abc"], ["xyz"])) #OUT 7 + + diff --git a/tests/accept/run/toprprec.nim b/tests/accept/run/toprprec.nim index 4728b2e68..17ec91fda 100755 --- a/tests/accept/run/toprprec.nim +++ b/tests/accept/run/toprprec.nim @@ -1,3 +1,7 @@ +discard """ + file: "toprprec.nim" + output: "done" +""" # Test operator precedence: assert 3+5*5-2 == 28- -26-28 @@ -10,3 +14,5 @@ assert 34 ^- 6 ^- 2 == 30 assert 34 - 6 - 2 == 26 echo "done" + + diff --git a/tests/accept/run/toverflw.nim b/tests/accept/run/toverflw.nim index 3dadcf13b..cd7b65acf 100755 --- a/tests/accept/run/toverflw.nim +++ b/tests/accept/run/toverflw.nim @@ -1,3 +1,7 @@ +discard """ + file: "toverflw.nim" + output: "the computation overflowed" +""" # Tests nimrod's ability to detect overflows {.push overflowChecks: on.} @@ -13,3 +17,5 @@ except EOverflow: {.pop.} # overflow check #OUT the computation overflowed + + diff --git a/tests/accept/run/toverflw2.nim b/tests/accept/run/toverflw2.nim index b54bda9fa..14a77ebad 100755 --- a/tests/accept/run/toverflw2.nim +++ b/tests/accept/run/toverflw2.nim @@ -1,5 +1,11 @@ +discard """ + file: "toverflw2.nim" + output: "Error: unhandled exception: over- or underflow [EOverflow]" +""" var a : int32 = 2147483647 var b : int32 = 2147483647 var c = a + b + + diff --git a/tests/accept/run/toverl2.nim b/tests/accept/run/toverl2.nim index 2d1225c6f..49b17da4d 100755 --- a/tests/accept/run/toverl2.nim +++ b/tests/accept/run/toverl2.nim @@ -1,3 +1,7 @@ +discard """ + file: "toverl2.nim" + output: "true012" +""" # Test new overloading resolution rules import strutils @@ -19,3 +23,5 @@ for x in toverl2(3): stdout.write("\n") #OUT true012 + + diff --git a/tests/accept/run/toverlop.nim b/tests/accept/run/toverlop.nim index f11275644..ce302345f 100755 --- a/tests/accept/run/toverlop.nim +++ b/tests/accept/run/toverlop.nim @@ -1,3 +1,7 @@ +discard """ + file: "toverlop.nim" + output: "3" +""" # Test operator overloading proc `%` (a, b: int): int = @@ -8,3 +12,5 @@ x = 15 y = 6 write(stdout, x % y) #OUT 3 + + diff --git a/tests/accept/run/toverwr.nim b/tests/accept/run/toverwr.nim index 6705c6b3f..ef25e8913 100755 --- a/tests/accept/run/toverwr.nim +++ b/tests/accept/run/toverwr.nim @@ -1,3 +1,7 @@ +discard """ + file: "toverwr.nim" + output: "hello" +""" # Test the overloading resolution in connection with a qualifier proc write(t: TFile, s: string) = @@ -5,3 +9,5 @@ proc write(t: TFile, s: string) = system.write(stdout, "hello") #OUT hello + + diff --git a/tests/accept/run/tovfint.nim b/tests/accept/run/tovfint.nim index 91eda8d0b..cfb1e649d 100755 --- a/tests/accept/run/tovfint.nim +++ b/tests/accept/run/tovfint.nim @@ -1,3 +1,7 @@ +discard """ + file: "tovfint.nim" + output: "works!" +""" # this tests the new overflow literals var @@ -15,3 +19,5 @@ else: write(stdout, "broken!\n") #OUT works! + + diff --git a/tests/accept/run/tpos.nim b/tests/accept/run/tpos.nim index df701d3c5..3d72536dd 100755 --- a/tests/accept/run/tpos.nim +++ b/tests/accept/run/tpos.nim @@ -1,3 +1,7 @@ +discard """ + file: "tpos.nim" + output: "6" +""" # test this particular function proc mypos(sub, s: string, start: int = 0): int = @@ -27,3 +31,5 @@ var sub = "hello" var s = "world hello" write(stdout, mypos(sub, s)) #OUT 6 + + diff --git a/tests/accept/run/tprintf.nim b/tests/accept/run/tprintf.nim index 14687a937..c8fb51cdc 100755 --- a/tests/accept/run/tprintf.nim +++ b/tests/accept/run/tprintf.nim @@ -1,3 +1,7 @@ +discard """ + file: "tprintf.nim" + output: "Andreas Rumpf" +""" # Test a printf proc proc printf(file: TFile, args: openarray[string]) = @@ -8,3 +12,5 @@ proc printf(file: TFile, args: openarray[string]) = printf(stdout, ["Andreas ", "Rumpf\n"]) #OUT Andreas Rumpf + + diff --git a/tests/accept/run/tprocvar.nim b/tests/accept/run/tprocvar.nim index f51543dfa..237e2ef7a 100755 --- a/tests/accept/run/tprocvar.nim +++ b/tests/accept/run/tprocvar.nim @@ -1,3 +1,7 @@ +discard """ + file: "tprocvar.nim" + output: "papbpcpdpe7" +""" # test variables of type proc proc pa() {.cdecl.} = write(stdout, "pa") @@ -24,3 +28,5 @@ discard x(3, 4) #OUT papbpcpdpe7 + + diff --git a/tests/accept/run/tquotewords.nim b/tests/accept/run/tquotewords.nim index 462293b40..81f30c9a9 100755 --- a/tests/accept/run/tquotewords.nim +++ b/tests/accept/run/tquotewords.nim @@ -1,3 +1,7 @@ +discard """ + file: "tquotewords.nim" + output: "thisanexample" +""" # Test an idea I recently had: import macros @@ -17,3 +21,5 @@ for w in items(myWordList): echo s #OUT thisanexample + + diff --git a/tests/accept/run/tregex.nim b/tests/accept/run/tregex.nim index 882f98132..7ac628c4d 100755 --- a/tests/accept/run/tregex.nim +++ b/tests/accept/run/tregex.nim @@ -1,3 +1,7 @@ +discard """ + file: "tregex.nim" + output: "key: keyAYes!" +""" # Test the new regular expression module # which is based on the PCRE library @@ -18,3 +22,5 @@ else: echo("Bug!") #OUT key: keyAYes! + + diff --git a/tests/accept/run/treguse.nim b/tests/accept/run/treguse.nim index dc805fc70..a610ad725 100755 --- a/tests/accept/run/treguse.nim +++ b/tests/accept/run/treguse.nim @@ -1,3 +1,7 @@ +discard """ + file: "treguse.nim" + output: "055this should be the casehugh" +""" # Test the register usage of the virtual machine and # the blocks in var statements @@ -19,3 +23,5 @@ proc main(a, b: int) = main(45, 1000) #OUT 055this should be the casehugh + + diff --git a/tests/accept/run/treraise.nim b/tests/accept/run/treraise.nim index 18f2b5f54..7e147c336 100755 --- a/tests/accept/run/treraise.nim +++ b/tests/accept/run/treraise.nim @@ -1,3 +1,7 @@ +discard """ + file: "treraise.nim" + output: "Error: unhandled exception: bla [ESomeOtherErr]" +""" type ESomething = object of E_Base ESomeOtherErr = object of E_Base @@ -15,3 +19,5 @@ except ESomething: except: raise + + diff --git a/tests/accept/run/tromans.nim b/tests/accept/run/tromans.nim index 12deca1ea..fa6a63595 100755 --- a/tests/accept/run/tromans.nim +++ b/tests/accept/run/tromans.nim @@ -1,3 +1,7 @@ +discard """ + file: "tromans.nim" + output: "success" +""" import strutils @@ -63,3 +67,5 @@ for i in items([1238, 1777, 3830, 2401, 379, 33, 940, 3973]): echo "success" #OUT success + + diff --git a/tests/accept/run/tseqcon.nim b/tests/accept/run/tseqcon.nim index 935da86b5..6e0a5b56d 100755 --- a/tests/accept/run/tseqcon.nim +++ b/tests/accept/run/tseqcon.nim @@ -1,3 +1,7 @@ +discard """ + file: "tseqcon.nim" + output: "Hithere, what\'s your name?Hathere, what\'s your name?" +""" # Test the add proc for sequences and strings const @@ -43,3 +47,5 @@ when nestedFixed: nested() #OUT Hithere, what's your name?Hathere, what's your name? + + diff --git a/tests/accept/run/tseqtuple.nim b/tests/accept/run/tseqtuple.nim index 975521c56..7ef92f7f1 100755 --- a/tests/accept/run/tseqtuple.nim +++ b/tests/accept/run/tseqtuple.nim @@ -1,3 +1,7 @@ +discard """ + file: "tseqtuple.nim" + output: "fA13msg1falsefB14msg2truefC15msg3false" +""" type TMsg = tuple[ @@ -20,3 +24,5 @@ for file, line, msg, err in items(s): #OUT fA13msg1falsefB14msg2truefC15msg3false + + diff --git a/tests/accept/run/tsets.nim b/tests/accept/run/tsets.nim index 08ab3e54b..7b806f15b 100755 --- a/tests/accept/run/tsets.nim +++ b/tests/accept/run/tsets.nim @@ -1,3 +1,7 @@ +discard """ + file: "tsets.nim" + output: "Ha ein F ist in s!" +""" # Test the handling of sets import @@ -56,3 +60,5 @@ for x in low(TTokTypeRange) .. high(TTokTypeRange): #writeln(stdout, "the token '$1' is in the set" % repr(x)) #OUT Ha ein F ist in s! + + diff --git a/tests/accept/run/tsidee2.nim b/tests/accept/run/tsidee2.nim index 2eaec01d7..e73c89608 100755 --- a/tests/accept/run/tsidee2.nim +++ b/tests/accept/run/tsidee2.nim @@ -1,3 +1,7 @@ +discard """ + file: "tsidee2.nim" + output: "5" +""" var global: int @@ -9,3 +13,5 @@ proc SideEffectLyer(x, y: int): int {.noSideEffect.} = echo SideEffectLyer(1, 3) #OUT 5 + + diff --git a/tests/accept/run/tsidee3.nim b/tests/accept/run/tsidee3.nim index be94192e7..e0c427ab6 100755 --- a/tests/accept/run/tsidee3.nim +++ b/tests/accept/run/tsidee3.nim @@ -1,3 +1,7 @@ +discard """ + file: "tsidee3.nim" + output: "5" +""" var global: int @@ -9,3 +13,5 @@ proc noSideEffect(x, y: int, p: proc (a: int): int {.noSideEffect.}): int {.noSi echo noSideEffect(1, 3, dontcare) #OUT 5 + + diff --git a/tests/accept/run/tsimmeth.nim b/tests/accept/run/tsimmeth.nim index c6dbf69bb..11ff2674f 100755 --- a/tests/accept/run/tsimmeth.nim +++ b/tests/accept/run/tsimmeth.nim @@ -1,3 +1,7 @@ +discard """ + file: "tsimmeth.nim" + output: "HELLO WORLD!" +""" # Test method simulation import strutils @@ -6,3 +10,5 @@ var x = "hello world!".toLower.toUpper x.echo() #OUT HELLO WORLD! + + diff --git a/tests/accept/run/tsplit.nim b/tests/accept/run/tsplit.nim index 711696b9e..25bad33e2 100755 --- a/tests/accept/run/tsplit.nim +++ b/tests/accept/run/tsplit.nim @@ -1,3 +1,7 @@ +discard """ + file: "tsplit.nim" + output: "true" +""" import strutils var s = "" @@ -12,3 +16,5 @@ else: #OUT true + + diff --git a/tests/accept/run/tstrange.nim b/tests/accept/run/tstrange.nim index 13aab2302..3947755fc 100755 --- a/tests/accept/run/tstrange.nim +++ b/tests/accept/run/tstrange.nim @@ -1,3 +1,7 @@ +discard """ + file: "tstrange.nim" + output: "hallo4" +""" # test for extremely strange bug proc ack(x: int, y: int): int = @@ -15,3 +19,5 @@ gen("hallo") write(stdout, ack(5, 4)) #OUT hallo4 + + diff --git a/tests/accept/run/tstrlits.nim b/tests/accept/run/tstrlits.nim index 48ae08212..1cd43975a 100755 --- a/tests/accept/run/tstrlits.nim +++ b/tests/accept/run/tstrlits.nim @@ -1,3 +1,7 @@ +discard """ + file: "tstrlits.nim" + output: "a\"\"long string\"\"\"\"\"abc\"def" +""" # Test the new different string literals const @@ -12,3 +16,5 @@ stdout.write(tripleEmpty) stdout.write(raw) #OUT a""long string"""""abc"def + + diff --git a/tests/accept/run/tstrutil.nim b/tests/accept/run/tstrutil.nim index 0488d1dc7..80c2f3870 100755 --- a/tests/accept/run/tstrutil.nim +++ b/tests/accept/run/tstrutil.nim @@ -1,3 +1,7 @@ +discard """ + file: "tstrutil.nim" + output: "ha/home/a1xyz/usr/bin" +""" # test the new strutils module import @@ -37,3 +41,5 @@ assert(editDistance("prefix__hallo_suffix", "prefix__hao_suffix") == 2) main() #OUT ha/home/a1xyz/usr/bin + + diff --git a/tests/accept/run/tunhandledexc.nim b/tests/accept/run/tunhandledexc.nim index 36ba5418d..c60de2234 100755 --- a/tests/accept/run/tunhandledexc.nim +++ b/tests/accept/run/tunhandledexc.nim @@ -1,3 +1,7 @@ +discard """ + file: "tunhandledexc.nim" + output: "Error: unhandled exception: bla [ESomeOtherErr]" +""" type ESomething = object of E_Base ESomeOtherErr = object of E_Base @@ -14,3 +18,5 @@ when True: except ESomething: echo("Error happened") + + diff --git a/tests/accept/run/tvardecl.nim b/tests/accept/run/tvardecl.nim index 496601e3a..5cc6f4960 100755 --- a/tests/accept/run/tvardecl.nim +++ b/tests/accept/run/tvardecl.nim @@ -1,3 +1,7 @@ +discard """ + file: "tvardecl.nim" + output: "44" +""" # Test the new variable declaration syntax var @@ -7,3 +11,5 @@ var write(stdout, a) write(stdout, b) #OUT 44 + + diff --git a/tests/accept/run/tvariantasgn.nim b/tests/accept/run/tvariantasgn.nim index 2cc38f434..46cc23dd1 100755 --- a/tests/accept/run/tvariantasgn.nim +++ b/tests/accept/run/tvariantasgn.nim @@ -1,3 +1,7 @@ +discard """ + file: "tvariantasgn.nim" + output: "came here" +""" #BUG type TAnyKind = enum @@ -22,3 +26,5 @@ nr.intVal = 78 # s = nr # works nr = s # fails! echo "came here" + + diff --git a/tests/accept/run/tvariantstack.nim b/tests/accept/run/tvariantstack.nim index e7378ce9a..d81f6e001 100755 --- a/tests/accept/run/tvariantstack.nim +++ b/tests/accept/run/tvariantstack.nim @@ -1,3 +1,7 @@ +discard """ + file: "tvariantstack.nim" + output: "came here" +""" #BUG type TAnyKind = enum @@ -44,3 +48,5 @@ stack.push(nr) var t = stack.pop() echo "came here" + + diff --git a/tests/accept/run/tvarnums.nim b/tests/accept/run/tvarnums.nim index 1b683ad94..4f99df8b9 100755 --- a/tests/accept/run/tvarnums.nim +++ b/tests/accept/run/tvarnums.nim @@ -1,3 +1,7 @@ +discard """ + file: "tvarnums.nim" + output: "Success!" +""" # Test variable length binary integers import @@ -134,3 +138,5 @@ tm(low(int32)) tm(high(int32)) writeln(stdout, "Success!") #OUT Success! + + diff --git a/tests/accept/run/tvartup.nim b/tests/accept/run/tvartup.nim index 05b00b207..f885cdf37 100755 --- a/tests/accept/run/tvartup.nim +++ b/tests/accept/run/tvartup.nim @@ -1,3 +1,7 @@ +discard """ + file: "tvartup.nim" + output: "2 3" +""" # Test the new tuple unpacking proc divmod(a, b: int): tuple[di, mo: int] = @@ -9,3 +13,5 @@ stdout.write(" ") stdout.write(y) #OUT 2 3 + + diff --git a/tests/accept/run/twrongexc.nim b/tests/accept/run/twrongexc.nim index 8ba07bbce..592693769 100755 --- a/tests/accept/run/twrongexc.nim +++ b/tests/accept/run/twrongexc.nim @@ -1,6 +1,12 @@ +discard """ + file: "twrongexc.nim" + output: "Error: unhandled exception [EInvalidValue]" +""" try: raise newException(EInvalidValue, "") except EOverflow: echo("Error caught") + + diff --git a/tests/accept/run/txmlgen.nim b/tests/accept/run/txmlgen.nim index 56ca42d53..4d5271563 100755 --- a/tests/accept/run/txmlgen.nim +++ b/tests/accept/run/txmlgen.nim @@ -1,6 +1,12 @@ +discard """ + file: "txmlgen.nim" + output: "<h1><a href=\"http://force7.de/nimrod\">Nimrod</a></h1>" +""" import xmlgen var nim = "Nimrod" echo h1(a(href="http://force7.de/nimrod", nim)) + + diff --git a/tests/accept/run/txmltree.nim b/tests/accept/run/txmltree.nim index 2e5f52576..931871f15 100755 --- a/tests/accept/run/txmltree.nim +++ b/tests/accept/run/txmltree.nim @@ -1,3 +1,7 @@ +discard """ + file: "txmltree.nim" + output: "true" +""" import xmltree, strtabs @@ -5,3 +9,5 @@ var x = <>a(href="nimrod.de", newText("www.nimrod-test.de")) echo($x == "<a href=\"nimrod.de\">www.nimrod-test.de</a>") + + diff --git a/tests/reject/spec.csv b/tests/reject/spec.csv deleted file mode 100755 index f2d38f03b..000000000 --- a/tests/reject/spec.csv +++ /dev/null @@ -1,41 +0,0 @@ -t99bott.nim;20;constant expression expected -tadrdisc.nim;15;for a 'var' type a variable needs to be passed -tambsym.nim;6;ambiguous identifier -tambsym2.nim;4;undeclared identifier: 'CreateRGBSurface' -tambsym3.nim;6;ambiguous identifier -tarraycons.nim;9;invalid order in array constructor -tatomic.nim;2;identifier expected, but found 'atomic' -tbind2.nim;7;ambiguous call -tbind4.nim;4;undeclared identifier: 'lastId' -tblock1.nim;9;undeclared identifier: 'ha' -tconstr1.nim;20;type mismatch -tillrec.nim;8;illegal recursion in type 'TIllegal' -tinc.nim;3;for a 'var' type a variable needs to be passed -tinout.nim;7;for a 'var' type a variable needs to be passed -tinvalidnewseq.nim;10;type mismatch: got (array[0..6, string], int) -tinvwhen.nim;6;invalid indentation -titer4.nim;2;iterator within for loop context expected -tmethod.nim;2;'method' needs a parameter that has an object type -tnamedparams.nim;3; Error: type mismatch: got (input: string, filename: string, line: int, col: int) -tnamspc.nim;5;undeclared identifier: 'global' -tnoop.nim;6;expression 'a()' cannot be called -tnot.nim;9;type mismatch -topaque.nim;11;undeclared field: 'buffer' -topena1.nim;4;invalid type -toverl.nim;6;attempt to redefine 'TNone' -trawstr.nim;5;closing " expected -trecinca.nim;3;recursive dependency: 'tests/reject/trecincb.nim' -trecincb.nim;4;recursive dependency: 'tests/reject/trecincb.nim' -treciter.nim;4;recursive dependency: 'myrec' -trectype.nim;20;internal error: cannot generate C type for: PA -trefs.nim;15;type mismatch -tsidee1.nim;7;'SideEffectLyer' can have side effects -tsidee4.nim;10;type mismatch -tsimtych.nim;5;type mismatch: got (bool) but expected 'string' -tstatret.nim;4;statement not allowed after -tstmtexp.nim;3;value returned by statement has to be discarded -ttempl2.nim;13;undeclared identifier: 'b' -ttypelessemptyset.nim;0;Error: internal error: invalid kind for last(tyEmpty) -tunderscores.nim;3;invalid token: _ -twrongtupleaccess.nim;4;undeclared field: 'setBLAH' -typredef.nim;2;illegal recursion in type 'Uint8' diff --git a/tests/reject/t99bott.nim b/tests/reject/t99bott.nim index 4dfb11701..b514b49d9 100755 --- a/tests/reject/t99bott.nim +++ b/tests/reject/t99bott.nim @@ -1,3 +1,8 @@ +discard """ + file: "t99bott.nim" + line: 25 + errormsg: "constant expression expected" +""" ## 99 Bottles of Beer ## http://www.99-bottles-of-beer.net/ ## Nimrod version @@ -26,3 +31,5 @@ echo "No more bottles of beer on the wall, no more bottles of beer." echo "Go to the store and buy some more, 99 bottles of beer on the wall." + + diff --git a/tests/reject/tadrdisc.nim b/tests/reject/tadrdisc.nim index a7118455f..0e0324562 100755 --- a/tests/reject/tadrdisc.nim +++ b/tests/reject/tadrdisc.nim @@ -1,3 +1,8 @@ +discard """ + file: "tadrdisc.nim" + line: 20 + errormsg: "for a \'var\' type a variable needs to be passed" +""" # Test that the address of a dicriminants cannot be taken type @@ -14,3 +19,5 @@ proc setKind(k: var TKind) = var a: TA setKind(a.k) #ERROR_MSG for a 'var' type a variable needs to be passed + + diff --git a/tests/reject/tambsym.nim b/tests/reject/tambsym.nim index b8eae3ba3..902274648 100755 --- a/tests/reject/tambsym.nim +++ b/tests/reject/tambsym.nim @@ -1,3 +1,8 @@ +discard """ + file: "tambsym.nim" + line: 11 + errormsg: "ambiguous identifier" +""" # Test ambiguous symbols import mambsym1, mambsym2 @@ -6,3 +11,5 @@ var v: TExport #ERROR_MSG ambiguous identifier v = y + + diff --git a/tests/reject/tambsym2.nim b/tests/reject/tambsym2.nim index 3318f3fe2..98327354d 100755 --- a/tests/reject/tambsym2.nim +++ b/tests/reject/tambsym2.nim @@ -1,6 +1,13 @@ +discard """ + file: "tambsym2.nim" + line: 9 + errormsg: "undeclared identifier: \'CreateRGBSurface\'" +""" from sdl import PSurface discard SDL.CreateRGBSurface(SDL.SWSURFACE, 23, 34, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xff000000'i32) + + diff --git a/tests/reject/tambsym3.nim b/tests/reject/tambsym3.nim index 96a5098c9..0155f258c 100755 --- a/tests/reject/tambsym3.nim +++ b/tests/reject/tambsym3.nim @@ -1,3 +1,8 @@ +discard """ + file: "tambsym3.nim" + line: 11 + errormsg: "ambiguous identifier" +""" # Test ambiguous symbols import mambsym1, times @@ -6,3 +11,5 @@ var v = mDec #ERROR_MSG ambiguous identifier writeln(stdout, ord(v)) + + diff --git a/tests/reject/tarraycons.nim b/tests/reject/tarraycons.nim index 1809f8735..7de518b6e 100755 --- a/tests/reject/tarraycons.nim +++ b/tests/reject/tarraycons.nim @@ -1,3 +1,8 @@ +discard """ + file: "tarraycons.nim" + line: 14 + errormsg: "invalid order in array constructor" +""" type TEnum = enum @@ -15,3 +20,5 @@ const echo myMapping[eC][1] + + diff --git a/tests/reject/tatomic.nim b/tests/reject/tatomic.nim index 0f1b8125d..bc119c3b3 100755 --- a/tests/reject/tatomic.nim +++ b/tests/reject/tatomic.nim @@ -1,5 +1,12 @@ +discard """ + file: "tatomic.nim" + line: 7 + errormsg: "identifier expected, but found \'atomic\'" +""" var atomic: int echo atomic + + diff --git a/tests/reject/tbind2.nim b/tests/reject/tbind2.nim index 41711083f..06065538e 100755 --- a/tests/reject/tbind2.nim +++ b/tests/reject/tbind2.nim @@ -1,3 +1,8 @@ +discard """ + file: "tbind2.nim" + line: 12 + errormsg: "ambiguous call" +""" # Test the new ``bind`` keyword for templates proc p1(x: int8, y: int): int = return x + y @@ -8,3 +13,5 @@ template tempBind(x, y: expr): expr = echo tempBind(1'i8, 2'i8) + + diff --git a/tests/reject/tbind4.nim b/tests/reject/tbind4.nim index d0b5fc062..ae525f06e 100755 --- a/tests/reject/tbind4.nim +++ b/tests/reject/tbind4.nim @@ -1,6 +1,13 @@ +discard """ + file: "tbind4.nim" + line: 9 + errormsg: "undeclared identifier: \'lastId\'" +""" # Module B import mbind4 echo genId() #ERROR_MSG instantiation from here + + diff --git a/tests/reject/tblock1.nim b/tests/reject/tblock1.nim index 0bea7ae7f..5c41aaf82 100755 --- a/tests/reject/tblock1.nim +++ b/tests/reject/tblock1.nim @@ -1,3 +1,8 @@ +discard """ + file: "tblock1.nim" + line: 14 + errormsg: "undeclared identifier: \'ha\'" +""" # check for forward label and # for failure when label is not declared @@ -9,3 +14,5 @@ proc main = break ha #ERROR main() + + diff --git a/tests/reject/tconstr1.nim b/tests/reject/tconstr1.nim index 488170350..cb6594213 100755 --- a/tests/reject/tconstr1.nim +++ b/tests/reject/tconstr1.nim @@ -1,3 +1,8 @@ +discard """ + file: "tconstr1.nim" + line: 25 + errormsg: "type mismatch" +""" # Test array, record constructors type @@ -21,3 +26,5 @@ const otherThings = [ # the same (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a'})] + + diff --git a/tests/reject/tillrec.nim b/tests/reject/tillrec.nim index 21ce19889..3f8fe60fc 100755 --- a/tests/reject/tillrec.nim +++ b/tests/reject/tillrec.nim @@ -1,3 +1,8 @@ +discard """ + file: "tillrec.nim" + line: 13 + errormsg: "illegal recursion in type \'TIllegal\'" +""" # test illegal recursive types type @@ -8,3 +13,5 @@ type TIllegal {.final.} = object #ERROR_MSG illegal recursion in type 'TIllegal' y: Int x: array[0..3, TIllegal] + + diff --git a/tests/reject/tinc.nim b/tests/reject/tinc.nim index 26fe32a41..8038a2a01 100755 --- a/tests/reject/tinc.nim +++ b/tests/reject/tinc.nim @@ -1,5 +1,12 @@ +discard """ + file: "tinc.nim" + line: 8 + errormsg: "for a \'var\' type a variable needs to be passed" +""" var x = 0 inc(x+1) + + diff --git a/tests/reject/tinout.nim b/tests/reject/tinout.nim index b4fe2fb10..034c496f5 100755 --- a/tests/reject/tinout.nim +++ b/tests/reject/tinout.nim @@ -1,3 +1,8 @@ +discard """ + file: "tinout.nim" + line: 12 + errormsg: "for a \'var\' type a variable needs to be passed" +""" # Test in out checking for parameters proc abc(x: var int) = @@ -7,3 +12,5 @@ proc b() = abc(3) #ERROR b() + + diff --git a/tests/reject/tinvalidnewseq.nim b/tests/reject/tinvalidnewseq.nim index ccd327284..a8cc36783 100755 --- a/tests/reject/tinvalidnewseq.nim +++ b/tests/reject/tinvalidnewseq.nim @@ -1,3 +1,8 @@ +discard """ + file: "tinvalidnewseq.nim" + line: 15 + errormsg: "type mismatch: got (array[0..6, string], int)" +""" import re, strutils type @@ -18,3 +23,5 @@ var r: TUrl r = parseUrl(r"http://google.com/search?var=bleahdhsad") echo(r.domain) + + diff --git a/tests/reject/tinvwhen.nim b/tests/reject/tinvwhen.nim index 8dc8cbf50..ea8a7ddf0 100755 --- a/tests/reject/tinvwhen.nim +++ b/tests/reject/tinvwhen.nim @@ -1,3 +1,8 @@ +discard """ + file: "tinvwhen.nim" + line: 11 + errormsg: "invalid indentation" +""" # This was parsed even though it should not! proc chdir(path: CString): cint {.importc: "chdir", header: "dirHeader".} @@ -6,3 +11,5 @@ proc getcwd(buf: CString, buflen: cint): CString when defined(unix): {.importc: "getcwd", header: "<unistd.h>".} #ERROR_MSG invalid indentation elif defined(windows): {.importc: "getcwd", header: "<direct.h>"} else: {.error: "os library not ported to your OS. Please help!".} + + diff --git a/tests/reject/titer4.nim b/tests/reject/titer4.nim index 376522482..d9d885543 100755 --- a/tests/reject/titer4.nim +++ b/tests/reject/titer4.nim @@ -1,3 +1,10 @@ +discard """ + file: "titer4.nim" + line: 7 + errormsg: "iterator within for loop context expected" +""" for x in {'a'..'z'}: #ERROR_MSG iterator within for loop context expected nil + + diff --git a/tests/reject/tmethod.nim b/tests/reject/tmethod.nim index 101cabf25..999016072 100755 --- a/tests/reject/tmethod.nim +++ b/tests/reject/tmethod.nim @@ -1,4 +1,11 @@ +discard """ + file: "tmethod.nim" + line: 7 + errormsg: "\'method\' needs a parameter that has an object type" +""" method m(i: int): int = return 5 + + diff --git a/tests/reject/tnamedparams.nim b/tests/reject/tnamedparams.nim index 6c59518b3..1772bd938 100755 --- a/tests/reject/tnamedparams.nim +++ b/tests/reject/tnamedparams.nim @@ -1,3 +1,8 @@ +discard """ + file: "tnamedparams.nim" + line: 8 + errormsg: "Error: type mismatch: got (input: string, filename: string, line: int, col: int)" +""" import pegs discard parsePeg( @@ -6,3 +11,5 @@ discard parsePeg( line = 1, col = 23) + + diff --git a/tests/reject/tnamspc.nim b/tests/reject/tnamspc.nim index eddaacfd8..1e2049cec 100755 --- a/tests/reject/tnamspc.nim +++ b/tests/reject/tnamspc.nim @@ -1,5 +1,12 @@ +discard """ + file: "tnamspc.nim" + line: 10 + errormsg: "undeclared identifier: \'global\'" +""" # Test17 - test correct handling of namespaces import mnamspc1 global = 9 #ERROR + + diff --git a/tests/reject/tnoop.nim b/tests/reject/tnoop.nim index d097553e8..2d320c849 100755 --- a/tests/reject/tnoop.nim +++ b/tests/reject/tnoop.nim @@ -1,6 +1,13 @@ +discard """ + file: "tnoop.nim" + line: 11 + errormsg: "expression \'a()\' cannot be called" +""" # Tests the new check in the semantic pass var a: int a() #ERROR_MSG expression 'a()' cannot be called + + diff --git a/tests/reject/tnot.nim b/tests/reject/tnot.nim index cda551654..cd0f538e6 100755 --- a/tests/reject/tnot.nim +++ b/tests/reject/tnot.nim @@ -1,3 +1,8 @@ +discard """ + file: "tnot.nim" + line: 14 + errormsg: "type mismatch" +""" # BUG: following compiles, but should not: proc nodeOfDegree(x: Int): bool = @@ -13,3 +18,5 @@ proc main = main() + + diff --git a/tests/reject/topaque.nim b/tests/reject/topaque.nim index 7553a749e..ac390835b 100755 --- a/tests/reject/topaque.nim +++ b/tests/reject/topaque.nim @@ -1,3 +1,8 @@ +discard """ + file: "topaque.nim" + line: 16 + errormsg: "undeclared field: \'buffer\'" +""" # Test the new opaque types import @@ -9,3 +14,5 @@ var L.filename = "ha" L.line = 34 L.buffer[0] = '\0' #ERROR_MSG undeclared field: 'buffer' + + diff --git a/tests/reject/topena1.nim b/tests/reject/topena1.nim index 7351edf55..0dbc5506a 100755 --- a/tests/reject/topena1.nim +++ b/tests/reject/topena1.nim @@ -1,5 +1,12 @@ +discard """ + file: "topena1.nim" + line: 9 + errormsg: "invalid type" +""" # Tests a special bug var x: ref openarray[string] #ERROR_MSG invalid type + + diff --git a/tests/reject/toverl.nim b/tests/reject/toverl.nim index 94f251cac..5c5f8d440 100755 --- a/tests/reject/toverl.nim +++ b/tests/reject/toverl.nim @@ -1,6 +1,13 @@ +discard """ + file: "toverl.nim" + line: 11 + errormsg: "attempt to redefine \'TNone\'" +""" # Test for overloading type TNone {.exportc: "_NONE", final.} = object proc TNone(a, b: int) = nil #ERROR_MSG attempt to redefine 'TNone' + + diff --git a/tests/reject/trawstr.nim b/tests/reject/trawstr.nim index 7b2db0335..ab2aae159 100755 --- a/tests/reject/trawstr.nim +++ b/tests/reject/trawstr.nim @@ -1,5 +1,12 @@ +discard """ + file: "trawstr.nim" + line: 10 + errormsg: "closing \" expected" +""" # Test the new raw strings: const xxx = r"This is a raw string!" yyy = "This not\" #ERROR + + diff --git a/tests/reject/trecinca.nim b/tests/reject/trecinca.nim index d78fee233..a567c84db 100755 --- a/tests/reject/trecinca.nim +++ b/tests/reject/trecinca.nim @@ -1,5 +1,12 @@ +discard """ + file: "trecinca.nim" + line: 8 + errormsg: "recursive dependency: \'tests/reject/trecincb.nim\'" +""" # Test recursive includes include trecincb #ERROR_MSG recursive dependency: 'tests/trecincb.nim' echo "trecina" + + diff --git a/tests/reject/trecincb.nim b/tests/reject/trecincb.nim index 6191671a1..937c5e488 100755 --- a/tests/reject/trecincb.nim +++ b/tests/reject/trecincb.nim @@ -1,6 +1,13 @@ +discard """ + file: "trecincb.nim" + line: 9 + errormsg: "recursive dependency: \'tests/reject/trecincb.nim\'" +""" # Test recursive includes include trecincb #ERROR_MSG recursive dependency: 'tests/trecincb.nim' echo "trecinb" + + diff --git a/tests/reject/treciter.nim b/tests/reject/treciter.nim index 662239285..dacdbdfd7 100755 --- a/tests/reject/treciter.nim +++ b/tests/reject/treciter.nim @@ -1,3 +1,8 @@ +discard """ + file: "treciter.nim" + line: 9 + errormsg: "recursive dependency: \'myrec\'" +""" # Test that an error message occurs for a recursive iterator iterator myrec(n: int): int = @@ -5,3 +10,5 @@ iterator myrec(n: int): int = yield x for x in myrec(10): echo x + + diff --git a/tests/reject/trectype.nim b/tests/reject/trectype.nim index a7a6f56e0..e9bf8234d 100755 --- a/tests/reject/trectype.nim +++ b/tests/reject/trectype.nim @@ -1,3 +1,8 @@ +discard """ + file: "trectype.nim" + line: 25 + errormsg: "internal error: cannot generate C type for: PA" +""" # Test recursive type descriptions # (mainly for the C code generator) @@ -19,3 +24,5 @@ var new(x) #ERROR_MSG internal error: cannot generate C type for: PA + + diff --git a/tests/reject/trefs.nim b/tests/reject/trefs.nim index ab3934088..b157ca2b5 100755 --- a/tests/reject/trefs.nim +++ b/tests/reject/trefs.nim @@ -1,3 +1,8 @@ +discard """ + file: "trefs.nim" + line: 20 + errormsg: "type mismatch" +""" # test for ref types (including refs to procs) type @@ -14,3 +19,5 @@ p = foo write(stdout, "success!") p = wrongfoo #ERROR_MSG type mismatch + + diff --git a/tests/reject/tsidee1.nim b/tests/reject/tsidee1.nim index 3bd520680..bd5b32dd7 100755 --- a/tests/reject/tsidee1.nim +++ b/tests/reject/tsidee1.nim @@ -1,3 +1,8 @@ +discard """ + file: "tsidee1.nim" + line: 12 + errormsg: "\'SideEffectLyer\' can have side effects" +""" var global: int @@ -9,3 +14,5 @@ proc SideEffectLyer(x, y: int): int {.noSideEffect.} = #ERROR_MSG 'SideEffectLye echo SideEffectLyer(1, 3) + + diff --git a/tests/reject/tsidee4.nim b/tests/reject/tsidee4.nim index 55c474d10..cbebfbd36 100755 --- a/tests/reject/tsidee4.nim +++ b/tests/reject/tsidee4.nim @@ -1,3 +1,8 @@ +discard """ + file: "tsidee4.nim" + line: 15 + errormsg: "type mismatch" +""" var global: int @@ -8,3 +13,5 @@ proc noSideEffect(x, y: int, p: proc (a: int): int {.noSideEffect.}): int {.noSi return x + y + dontcare(x) echo noSideEffect(1, 3, dontcare) #ERROR_MSG type mismatch + + diff --git a/tests/reject/tsimtych.nim b/tests/reject/tsimtych.nim index b100c62e3..dd969958c 100755 --- a/tests/reject/tsimtych.nim +++ b/tests/reject/tsimtych.nim @@ -1,5 +1,12 @@ +discard """ + file: "tsimtych.nim" + line: 10 + errormsg: "type mismatch: got (bool) but expected \'string\'" +""" # Test 2 # Simple type checking var a: string a = false #ERROR + + diff --git a/tests/reject/tstatret.nim b/tests/reject/tstatret.nim index ac93ac532..bf90255a0 100755 --- a/tests/reject/tstatret.nim +++ b/tests/reject/tstatret.nim @@ -1,5 +1,12 @@ +discard """ + file: "tstatret.nim" + line: 9 + errormsg: "statement not allowed after" +""" # no statement after return proc main() = return echo("huch?") #ERROR_MSG statement not allowed after + + diff --git a/tests/reject/tstmtexp.nim b/tests/reject/tstmtexp.nim index f4d83e83f..50248ad32 100755 --- a/tests/reject/tstmtexp.nim +++ b/tests/reject/tstmtexp.nim @@ -1,3 +1,10 @@ +discard """ + file: "tstmtexp.nim" + line: 8 + errormsg: "value returned by statement has to be discarded" +""" # Test 3 1+4 #ERROR_MSG value returned by statement has to be discarded + + diff --git a/tests/reject/ttempl2.nim b/tests/reject/ttempl2.nim index fba6bd0cb..fba988f95 100755 --- a/tests/reject/ttempl2.nim +++ b/tests/reject/ttempl2.nim @@ -1,3 +1,8 @@ +discard """ + file: "ttempl2.nim" + line: 18 + errormsg: "undeclared identifier: \'b\'" +""" template declareInScope(x: expr, t: typeDesc): stmt = var x: t @@ -12,3 +17,5 @@ a = 42 # works, `a` is known here declareInNewScope(b, int) b = 42 #ERROR_MSG undeclared identifier: 'b' + + diff --git a/tests/reject/ttypelessemptyset.nim b/tests/reject/ttypelessemptyset.nim index a49cb8fa0..2335de359 100755 --- a/tests/reject/ttypelessemptyset.nim +++ b/tests/reject/ttypelessemptyset.nim @@ -1,4 +1,11 @@ +discard """ + file: "ttypelessemptyset.nim" + line: 5 + errormsg: "Error: internal error: invalid kind for last(tyEmpty)" +""" var q = false discard (if q: {} else: {}) + + diff --git a/tests/reject/tunderscores.nim b/tests/reject/tunderscores.nim index 459cfda30..8075fdae4 100755 --- a/tests/reject/tunderscores.nim +++ b/tests/reject/tunderscores.nim @@ -1,3 +1,8 @@ +discard """ + file: "tunderscores.nim" + line: 8 + errormsg: "invalid token: _" +""" # Bug #502670 var ef_ = 3 #ERROR_MSG invalid token: _ @@ -5,3 +10,5 @@ var a__b = 1 var c___d = 2 echo(ab, cd, ef_) + + diff --git a/tests/reject/twrongtupleaccess.nim b/tests/reject/twrongtupleaccess.nim index f706e267c..bb09b108d 100755 --- a/tests/reject/twrongtupleaccess.nim +++ b/tests/reject/twrongtupleaccess.nim @@ -1,5 +1,12 @@ +discard """ + file: "twrongtupleaccess.nim" + line: 9 + errormsg: "undeclared field: \'setBLAH\'" +""" # Bugfix var v = (5.0, 10.0) v.setBLAH(10) + + diff --git a/tests/reject/typredef.nim b/tests/reject/typredef.nim index a77d91f40..b2182d116 100755 --- a/tests/reject/typredef.nim +++ b/tests/reject/typredef.nim @@ -1,3 +1,10 @@ +discard """ + file: "typredef.nim" + line: 7 + errormsg: "illegal recursion in type \'Uint8\'" +""" type Uint8 = Uint8 #ERROR_MSG illegal recursion in type 'Uint8' + + diff --git a/tests/tester.nim b/tests/tester.nim index 1c21e7afc..37dbf1388 100755 --- a/tests/tester.nim +++ b/tests/tester.nim @@ -10,7 +10,7 @@ ## This program verifies Nimrod against the testcases. import - strutils, pegs, os, osproc, streams, parsecsv, browsers + parseutils, strutils, pegs, os, osproc, streams, parsecfg, browsers const cmdTemplate = r"nimrod cc --hints:on $# $#" @@ -21,12 +21,72 @@ type file: string, line: int, msg: string, - err: bool] - TOutp = tuple[file, outp: string] + err: bool, + disabled: bool] + TOutp = tuple[file, outp: string, disabled: bool] TResults = object - total, passed: int + total, passed, skipped: int data: string +# ----------------------- Spec parser ---------------------------------------- + +when not defined(parseCfgBool): + # candidate for the stdlib: + proc parseCfgBool(s: string): bool = + case normalize(s) + of "y", "yes", "true", "1", "on": result = true + of "n", "no", "false", "0", "off": result = false + else: raise newException(EInvalidValue, "cannot interpret as a bool: " & s) + +proc extractSpec(filename: string): string = + const tripleQuote = "\"\"\"" + var x = readFile(filename) + if isNil(x): quit "cannot open file: " & filename + var a = x.find(tripleQuote) + var b = x.find(tripleQuote, a+3) + if a >= 0 and b > a: + result = x.copy(a+3, b-1).replace("'''", tripleQuote) + else: + echo "warning: file does not contain spec: " & filename + +template parseTest(fillResult: stmt) = + var ss = newStringStream(extractSpec(filename)) + var p: TCfgParser + open(p, ss, filename, 1) + while true: + var e = next(p) + case e.kind + of cfgEof: break + of cfgSectionStart, cfgOption, cfgError: + echo ignoreMsg(p, e) + of cfgKeyValuePair: + fillResult + close(p) + +proc parseRejectTest(filename: string): TMsg = + result.file = filename + result.err = true + result.msg = "" + parseTest: + case normalize(e.key) + of "file": result.file = e.value + of "line": discard parseInt(e.value, result.line) + of "errormsg": result.msg = e.value + of "disabled": result.disabled = parseCfgBool(e.value) + else: echo ignoreMsg(p, e) + +proc parseRunTest(filename: string): TOutp = + result.file = filename + result.outp = "" + parseTest: + case normalize(e.key) + of "file": result.file = e.value + of "output": result.outp = e.value + of "disabled": result.disabled = parseCfgBool(e.value) + else: echo ignoreMsg(p, e) + +# ---------------------------------------------------------------------------- + proc myExec(cmd: string): string = result = osproc.execProcess(cmd) @@ -62,38 +122,16 @@ proc callCompiler(filename, options: string): TMsg = elif s =~ pegSuccess: result.err = false -proc setupCvsParser(csvFile: string): TCsvParser = - var s = newFileStream(csvFile, fmRead) - if s == nil: quit("cannot open the file" & csvFile) - result.open(s, csvFile, separator=';', skipInitialSpace=true) - -proc parseRejectData(dir: string): seq[TMsg] = - var p = setupCvsParser(dir / "spec.csv") - result = @[] - while readRow(p, 3): - result.add((p.row[0], parseInt(p.row[1]), p.row[2], true)) - close(p) - -proc parseRunData(dir: string): seq[TOutp] = - var p = setupCvsParser(dir / "spec.csv") - result = @[] - while readRow(p, 2): - result.add((p.row[0], p.row[1])) - close(p) - -proc findSpec[T](specs: seq[T], filename: string): int = - while result < specs.len: - if specs[result].file == filename: return - inc(result) - quit("cannot find spec for file: " & filename) - proc initResults: TResults = result.total = 0 result.passed = 0 + result.skipped = 0 result.data = "" proc `$`(x: TResults): string = - result = "Tests passed: " & $x.passed & "/" & $x.total & "<br />\n" + result = ("Tests passed: $1 / $3 <br />\n" & + "Tests skipped: $2 / $3 <br />\n") % + [$x.passed, $x.skipped, $x.total] proc colorBool(b: bool): string = if b: result = "<span style=\"color:green\">yes</span>" @@ -147,15 +185,15 @@ proc cmpMsgs(r: var TResults, expected, given: TMsg, test: string) = proc reject(r: var TResults, dir, options: string) = ## handle all the tests that the compiler should reject - var specs = parseRejectData(dir) - for test in os.walkFiles(dir / "t*.nim"): var t = extractFilename(test) inc(r.total) echo t - var expected = findSpec(specs, t) - var given = callCompiler(test, options) - cmpMsgs(r, specs[expected], given, t) + var expected = parseRejectTest(test) + if expected.disabled: inc(r.skipped) + else: + var given = callCompiler(test, options) + cmpMsgs(r, expected, given, t) proc compile(r: var TResults, pattern, options: string) = for test in os.walkFiles(pattern): @@ -167,24 +205,25 @@ proc compile(r: var TResults, pattern, options: string) = if not given.err: inc(r.passed) proc run(r: var TResults, dir, options: string) = - var specs = parseRunData(dir) for test in os.walkFiles(dir / "t*.nim"): var t = extractFilename(test) - inc(r.total) echo t - var given = callCompiler(test, options) - if given.err: - r.addResult(t, "", given.msg, not given.err) + inc(r.total) + var expected = parseRunTest(test) + if expected.disabled: inc(r.skipped) else: - var exeFile = changeFileExt(test, ExeExt) - var expected = specs[findSpec(specs, t)] - if existsFile(exeFile): - var buf = myExec(exeFile) - var success = strip(buf) == strip(expected.outp) - if success: inc(r.passed) - r.addResult(t, expected.outp, buf, success) + var given = callCompiler(test, options) + if given.err: + r.addResult(t, "", given.msg, not given.err) else: - r.addResult(t, expected.outp, "executable not found", false) + var exeFile = changeFileExt(test, ExeExt) + if existsFile(exeFile): + var buf = myExec(exeFile) + var success = strip(buf) == strip(expected.outp) + if success: inc(r.passed) + r.addResult(t, expected.outp, buf, success) + else: + r.addResult(t, expected.outp, "executable not found", false) var options = "" var rejectRes = initResults() @@ -202,3 +241,4 @@ compile(compileRes, "examples/gtk/*.nim", options) run(runRes, "tests/accept/run", options) listResults(rejectRes, compileRes, runRes) openDefaultBrowser(resultsFile) + |