diff options
author | Araq <rumpf_a@web.de> | 2014-01-13 02:10:03 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-01-13 02:10:03 +0100 |
commit | 20b5f31c03fb556ec0aa2428a40adbac004d8987 (patch) | |
tree | 58086941e7d6bb8f480ca1173a95722ada9435b2 /tests/reject | |
parent | 51ee524109cf7e3e86c676bc1676063a01bfd979 (diff) | |
download | Nim-20b5f31c03fb556ec0aa2428a40adbac004d8987.tar.gz |
new tester; all tests categorized
Diffstat (limited to 'tests/reject')
96 files changed, 0 insertions, 1656 deletions
diff --git a/tests/reject/99bottles.nim b/tests/reject/99bottles.nim deleted file mode 100644 index 14904ac0f..000000000 --- a/tests/reject/99bottles.nim +++ /dev/null @@ -1 +0,0 @@ -# Test if the compiler detects invalid module names diff --git a/tests/reject/mambsym1.nim b/tests/reject/mambsym1.nim deleted file mode 100644 index cf8ac5242..000000000 --- a/tests/reject/mambsym1.nim +++ /dev/null @@ -1,10 +0,0 @@ -import mambsym2 # import TExport - -type - TExport* = enum x, y, z - TOtherEnum* = enum mDec, mInc, mAssign - -proc ha() = - var - x: TExport # no error - nil diff --git a/tests/reject/mambsym2.nim b/tests/reject/mambsym2.nim deleted file mode 100644 index eac8de6ba..000000000 --- a/tests/reject/mambsym2.nim +++ /dev/null @@ -1,3 +0,0 @@ -type - TExport* = enum a, b, c - diff --git a/tests/reject/mnamspc1.nim b/tests/reject/mnamspc1.nim deleted file mode 100644 index da13c5f24..000000000 --- a/tests/reject/mnamspc1.nim +++ /dev/null @@ -1,2 +0,0 @@ -import mnamspc2 - diff --git a/tests/reject/mnamspc2.nim b/tests/reject/mnamspc2.nim deleted file mode 100644 index 84ef8533e..000000000 --- a/tests/reject/mnamspc2.nim +++ /dev/null @@ -1,3 +0,0 @@ -# export an identifier: -var - global*: int diff --git a/tests/reject/mopaque.nim b/tests/reject/mopaque.nim deleted file mode 100644 index 7eee4bd96..000000000 --- a/tests/reject/mopaque.nim +++ /dev/null @@ -1,7 +0,0 @@ -type - TLexer* {.final.} = object - line*: int - filename*: string - buffer: cstring - -proc noProcVar*(): int = 18 diff --git a/tests/reject/t99bott.nim b/tests/reject/t99bott.nim deleted file mode 100644 index d18cb0d5c..000000000 --- a/tests/reject/t99bott.nim +++ /dev/null @@ -1,36 +0,0 @@ -discard """ - file: "t99bott.nim" - line: 26 - errormsg: "cannot evaluate at compile time: bn" - disabled: false -""" -## 99 Bottles of Beer -## http://www.99-bottles-of-beer.net/ -## Nimrod version - -## Author: Philippe Lhoste <PhiLho(a)GMX.net> http://Phi.Lho.free.fr -# 2012-11-25 -# Loosely based on my old Lua version... Updated to current official lyrics. - -proc GetBottleNumber(n: int): string = - var bs: string - if n == 0: - bs = "No more bottles" - elif n == 1: - bs = "1 bottle" - else: - bs = $n & " bottles" - return bs & " of beer" - -for bn in countdown(99, 1): - const cur = GetBottleNumber(bn) - echo(cur, " on the wall, ", cur, ".") - echo("Take one down and pass it around, ", GetBottleNumber(bn-1), - " on the wall.\n") - -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/tactiontable2.nim b/tests/reject/tactiontable2.nim deleted file mode 100644 index 00b427603..000000000 --- a/tests/reject/tactiontable2.nim +++ /dev/null @@ -1,28 +0,0 @@ -discard """ - line: 21 - errormsg: "invalid type: 'TTable'" -""" - -import tables - -proc action1(arg: string) = - echo "action 1 ", arg - -proc action2(arg: string) = - echo "action 2 ", arg - -proc action3(arg: string) = - echo "action 3 ", arg - -proc action4(arg: string) = - echo "action 4 ", arg - -const - actionTable = { - "A": action1, - "B": action2, - "C": action3, - "D": action4}.toTable - -actionTable["C"]("arg") - diff --git a/tests/reject/tadrdisc.nim b/tests/reject/tadrdisc.nim deleted file mode 100644 index 0e0324562..000000000 --- a/tests/reject/tadrdisc.nim +++ /dev/null @@ -1,23 +0,0 @@ -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 - TKind = enum ka, kb, kc - TA = object - case k: TKind - of ka: x, y: int - of kb: a, b: string - of kc: c, d: float - -proc setKind(k: var TKind) = - k = kc - -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 deleted file mode 100644 index 902274648..000000000 --- a/tests/reject/tambsym.nim +++ /dev/null @@ -1,15 +0,0 @@ -discard """ - file: "tambsym.nim" - line: 11 - errormsg: "ambiguous identifier" -""" -# Test ambiguous symbols - -import mambsym1, mambsym2 - -var - v: TExport #ERROR_MSG ambiguous identifier - -v = y - - diff --git a/tests/reject/tambsym3.nim b/tests/reject/tambsym3.nim deleted file mode 100644 index 0155f258c..000000000 --- a/tests/reject/tambsym3.nim +++ /dev/null @@ -1,15 +0,0 @@ -discard """ - file: "tambsym3.nim" - line: 11 - errormsg: "ambiguous identifier" -""" -# Test ambiguous symbols - -import mambsym1, times - -var - v = mDec #ERROR_MSG ambiguous identifier - -writeln(stdout, ord(v)) - - diff --git a/tests/reject/tarraycons.nim b/tests/reject/tarraycons.nim deleted file mode 100644 index 7de518b6e..000000000 --- a/tests/reject/tarraycons.nim +++ /dev/null @@ -1,24 +0,0 @@ -discard """ - file: "tarraycons.nim" - line: 14 - errormsg: "invalid order in array constructor" -""" - -type - TEnum = enum - eA, eB, eC, eD, eE, eF - -const - myMapping: array[TEnum, array[0..1, int]] = [ - eA: [1, 2], - eC: [3, 4], - eB: [5, 6], - eD: [0: 8, 1: 9], - eE: [0: 8, 9], - eF: [2, 1: 9] - ] - -echo myMapping[eC][1] - - - diff --git a/tests/reject/tarrayplus.nim b/tests/reject/tarrayplus.nim deleted file mode 100644 index 8c7452e85..000000000 --- a/tests/reject/tarrayplus.nim +++ /dev/null @@ -1,13 +0,0 @@ -discard """ - msg: "type mismatch: got (array[0..2, float], array[0..1, float])" -""" - -proc `+`*[R, T] (v1, v2: array[R, T]): array[R, T] = - for i in low(v1)..high(v1): - result[i] = v1[i] + v2[i] - -var - v1: array[0..2, float] = [3.0, 1.2, 3.0] - v2: array[0..1, float] = [2.0, 1.0] - v3 = v1 + v2 - diff --git a/tests/reject/tatomic.nim b/tests/reject/tatomic.nim deleted file mode 100644 index 1fa0cff8d..000000000 --- a/tests/reject/tatomic.nim +++ /dev/null @@ -1,12 +0,0 @@ -discard """ - file: "tatomic.nim" - line: 7 - errormsg: "identifier expected, but found 'keyword atomic'" -""" -var - atomic: int - -echo atomic - - - diff --git a/tests/reject/tbind2.nim b/tests/reject/tbind2.nim deleted file mode 100644 index e8e21ad02..000000000 --- a/tests/reject/tbind2.nim +++ /dev/null @@ -1,17 +0,0 @@ -discard """ - file: "tbind2.nim" - line: 14 - errormsg: "ambiguous call" -""" -# Test the new ``bind`` keyword for templates - -proc p1(x: int8, y: int): int = return x + y -proc p1(x: int, y: int8): int = return x - y - -template tempBind(x, y: expr): expr = - (bind p1(x, y)) #ERROR_MSG ambiguous call - -echo tempBind(1'i8, 2'i8) - - - diff --git a/tests/reject/tbindtypedesc.nim b/tests/reject/tbindtypedesc.nim deleted file mode 100644 index d6fbae537..000000000 --- a/tests/reject/tbindtypedesc.nim +++ /dev/null @@ -1,12 +0,0 @@ -discard """ - line: 11 - file: "tbindtypedesc.nim" - errormsg: "type mismatch: got (typedesc[float], string)" -""" - -proc foo(T: typedesc; some: T) = - echo($some) - -foo int, 4 -foo float, "bad" - diff --git a/tests/reject/tblock1.nim b/tests/reject/tblock1.nim deleted file mode 100644 index 5c41aaf82..000000000 --- a/tests/reject/tblock1.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - file: "tblock1.nim" - line: 14 - errormsg: "undeclared identifier: \'ha\'" -""" -# check for forward label and -# for failure when label is not declared - -proc main = - block endLess: - write(stdout, "Muaahh!\N") - break endLess - - break ha #ERROR - -main() - - diff --git a/tests/reject/tcaseexpr1.nim b/tests/reject/tcaseexpr1.nim deleted file mode 100644 index e5e08e25e..000000000 --- a/tests/reject/tcaseexpr1.nim +++ /dev/null @@ -1,30 +0,0 @@ -discard """ - file: "tcaseexpr1.nim" - - line: 29 - errormsg: "type mismatch: got (string) but expected 'int'" - - line: 23 - errormsg: "not all cases are covered" -""" - -type - E = enum A, B, C - -proc foo(x): auto = - return case x - of 1..9: "digit" - else: "number" - -var r = foo(10) - -var x = C - -var t1 = case x: - of A: "a" - of B: "b" - -var t2 = case x: - of A: 10 - of B, C: "23" - diff --git a/tests/reject/tcaseoverlaprange.nim b/tests/reject/tcaseoverlaprange.nim deleted file mode 100644 index 5f24c3ca9..000000000 --- a/tests/reject/tcaseoverlaprange.nim +++ /dev/null @@ -1,15 +0,0 @@ -discard """ - line: 13 - errormsg: "duplicate case label" -""" - -type - TE = enum A, B, C, D - -var - e: TE - -case e -of A..D, B..C: - echo "redundant" -else: nil diff --git a/tests/reject/tcaseoverlaprange2.nim b/tests/reject/tcaseoverlaprange2.nim deleted file mode 100644 index d6e301508..000000000 --- a/tests/reject/tcaseoverlaprange2.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - line: 13 - errormsg: "duplicate case label" -""" - - - - -proc checkDuplicates(myval: int32): bool = - case myval - of 0x7B: - echo "this should not compile" - of 0x78 .. 0x7D: - result = true - else: - nil - -echo checkDuplicates(0x7B) diff --git a/tests/reject/tcheckedfield1.nim b/tests/reject/tcheckedfield1.nim deleted file mode 100644 index 5ade3a13a..000000000 --- a/tests/reject/tcheckedfield1.nim +++ /dev/null @@ -1,60 +0,0 @@ -discard """ - errormsg: "cannot prove that field 'x.s' is accessible" - line:51 -""" - -import strutils - -{.warning[ProveField]: on.} - -type - TNodeKind = enum - nkBinary, nkTernary, nkStr - PNode = ref TNode not nil - TNode = object - case k: TNodeKind - of nkBinary, nkTernary: a, b: PNode - of nkStr: s: string - - PList = ref object - data: string - next: PList - -proc getData(x: PList not nil) = - echo x.data - -var head: PList - -proc processList() = - var it = head - while it != nil: - getData(it) - it = it.next - -proc toString2(x: PNode): string = - if x.k < nkStr: - toString2(x.a) & " " & toString2(x.b) - else: - x.s - -proc toString(x: PNode): string = - case x.k - of nkTernary, nkBinary: - toString(x.a) & " " & toString(x.b) - of nkStr: - x.s - -proc toString3(x: PNode): string = - if x.k <= nkBinary: - toString3(x.a) & " " & toString3(x.b) - else: - x.s # x.k in {nkStr} --> fact: not (x.k <= nkBinary) - -proc p() = - var x: PNode = PNode(k: nkStr, s: "abc") - - let y = x - if not y.isNil: - echo toString(y), " ", toString2(y) - -p() diff --git a/tests/reject/tconstr1.nim b/tests/reject/tconstr1.nim deleted file mode 100644 index cb6594213..000000000 --- a/tests/reject/tconstr1.nim +++ /dev/null @@ -1,30 +0,0 @@ -discard """ - file: "tconstr1.nim" - line: 25 - errormsg: "type mismatch" -""" -# Test array, record constructors - -type - TComplexRecord = tuple[ - s: string, - x, y: int, - z: float, - chars: set[Char]] - -proc testSem = - var - things: array [0..1, TComplexRecord] = [ - (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), - (s: "hi", x: 69, y: 45, z: 1.0, chars: {'a', 'b', 'c'})] - write(stdout, things[0].x) - -const - things: array [0..1, TComplexRecord] = [ - (s: "hi", x: 69, y: 45, z: 0.0, chars: {'a', 'b', 'c'}), - (s: "hi", x: 69, y: 45, z: 1.0)] #ERROR - 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/tconstraints.nim b/tests/reject/tconstraints.nim deleted file mode 100644 index e61095fff..000000000 --- a/tests/reject/tconstraints.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - line: 16 - errormsg: "type mismatch: got (int literal(232))" -""" - -proc myGenericProc[T: object|tuple|ptr|ref|distinct](x: T): string = - result = $x - -type - TMyObj = tuple[x, y: int] - -var - x: TMyObj - -assert myGenericProc(x) == "(x: 0, y: 0)" -assert myGenericProc(232) == "232" - - diff --git a/tests/reject/tdeprecated.nim b/tests/reject/tdeprecated.nim deleted file mode 100644 index f41f0a72f..000000000 --- a/tests/reject/tdeprecated.nim +++ /dev/null @@ -1,11 +0,0 @@ -discard """ - line: 9 - errormsg: "'a' is deprecated [Deprecated]" -""" - -var - a {.deprecated.}: array[0..11, int] - -a[8] = 1 - - diff --git a/tests/reject/tdestructor.nim b/tests/reject/tdestructor.nim deleted file mode 100644 index da9192a3f..000000000 --- a/tests/reject/tdestructor.nim +++ /dev/null @@ -1,21 +0,0 @@ -discard """ - line: 20 - errormsg: " usage of a type with a destructor in a non destructible context" -""" - -type - TMyObj = object - x, y: int - p: pointer - -proc destruct(o: var TMyObj) {.destructor.} = - if o.p != nil: dealloc o.p - -proc open: TMyObj = - result = TMyObj(x: 1, y: 2, p: alloc(3)) - - -proc `$`(x: TMyObj): string = $x.y - -echo open() - diff --git a/tests/reject/tdisallowif.nim b/tests/reject/tdisallowif.nim deleted file mode 100644 index 18dfd1c82..000000000 --- a/tests/reject/tdisallowif.nim +++ /dev/null @@ -1,29 +0,0 @@ -discard """ - line: 24 - errormsg: "usage of 'disallowIf' is a user-defined error" - disabled: true -""" - -template optZero{x+x}(x: int): int = x*3 -template andthen{`*`(x,3)}(x: int): int = x*4 -template optSubstr1{x = substr(x, 0, b)}(x: string, b: int) = setlen(x, b+1) - -template disallowIf{ - if cond: action - else: action2 -}(cond: bool, action, action2: stmt) {.error.} = action - -var y = 12 -echo y+y - -var s: array[0..2, string] -s[0] = "hello" -s[0] = substr(s[0], 0, 2) - -echo s[0] - -if s[0] != "hi": - echo "do it" - echo "more branches" -else: - discard diff --git a/tests/reject/teffects1.nim b/tests/reject/teffects1.nim deleted file mode 100644 index b72e8b00c..000000000 --- a/tests/reject/teffects1.nim +++ /dev/null @@ -1,21 +0,0 @@ -discard """ - line: 1855 - file: "system.nim" - errormsg: "can raise an unlisted exception: ref EIO" -""" - -type - TObj = object {.pure, inheritable.} - TObjB = object of TObj - a, b, c: string - - EIO2 = ref object of EIO - -proc forw: int {. .} - -proc lier(): int {.raises: [EIO2].} = - writeln stdout, "arg" - -proc forw: int = - raise newException(EIO, "arg") - diff --git a/tests/reject/teffects2.nim b/tests/reject/teffects2.nim deleted file mode 100644 index 7e6b17c36..000000000 --- a/tests/reject/teffects2.nim +++ /dev/null @@ -1,20 +0,0 @@ -discard """ - line: 19 - errormsg: "can raise an unlisted exception: ref EIO" -""" - -type - TObj = object {.pure, inheritable.} - TObjB = object of TObj - a, b, c: string - - EIO2 = ref object of EIO - -proc forw: int {.raises: [].} - -proc lier(): int {.raises: [EIO].} = - writeln stdout, "arg" - -proc forw: int = - raise newException(EIO, "arg") - diff --git a/tests/reject/teffects3.nim b/tests/reject/teffects3.nim deleted file mode 100644 index 78543a929..000000000 --- a/tests/reject/teffects3.nim +++ /dev/null @@ -1,19 +0,0 @@ -discard """ - line: 18 - errormsg: "type mismatch" -""" - -type - TObj = object {.pure, inheritable.} - TObjB = object of TObj - a, b, c: string - fn: proc (): int {.tags: [].} - - EIO2 = ref object of EIO - -proc raiser(): int {.tags: [TObj, FWriteIO].} = - writeln stdout, "arg" - -var o: TObjB -o.fn = raiser - diff --git a/tests/reject/teffects4.nim b/tests/reject/teffects4.nim deleted file mode 100644 index 4584e6dc8..000000000 --- a/tests/reject/teffects4.nim +++ /dev/null @@ -1,24 +0,0 @@ -discard """ - line: 23 - errormsg: "type mismatch" -""" - -type - TObj = object {.pure, inheritable.} - TObjB = object of TObj - a, b, c: string - fn: proc (): int {.tags: [FReadIO].} - - EIO2 = ref object of EIO - -proc q() {.tags: [FIO].} = - nil - -proc raiser(): int = - writeln stdout, "arg" - if true: - q() - -var o: TObjB -o.fn = raiser - diff --git a/tests/reject/teffects5.nim b/tests/reject/teffects5.nim deleted file mode 100644 index d630a6fc4..000000000 --- a/tests/reject/teffects5.nim +++ /dev/null @@ -1,14 +0,0 @@ -discard """ - errormsg: "type mismatch" - line: 7 -""" - -proc p(q: proc() ): proc() {.tags: [], raises: [], closure.} = - return proc () = - q() - -let yay = p(proc () = raise newException(EIO, "IO")) - -proc main() {.raises: [], tags: [].} = yay() - -main() diff --git a/tests/reject/temptycaseobj.nim b/tests/reject/temptycaseobj.nim deleted file mode 100644 index 5c012746e..000000000 --- a/tests/reject/temptycaseobj.nim +++ /dev/null @@ -1,14 +0,0 @@ -discard """ - line: 11 - errormsg: "identifier expected, but found 'keyword of'" -""" - -type - TMyEnum = enum enA, enU, enO - TMyCase = object - case e: TMyEnum - of enA: - of enU: x, y: int - of enO: a, b: string - - diff --git a/tests/reject/tenumitems.nim b/tests/reject/tenumitems.nim deleted file mode 100644 index b6eee5ba8..000000000 --- a/tests/reject/tenumitems.nim +++ /dev/null @@ -1,9 +0,0 @@ -discard """ - line: 7 - errormsg: "type mismatch" -""" - -type a = enum b,c,d -a.items() - - diff --git a/tests/reject/tenummix.nim b/tests/reject/tenummix.nim deleted file mode 100644 index aaf0be2cb..000000000 --- a/tests/reject/tenummix.nim +++ /dev/null @@ -1,11 +0,0 @@ -discard """ - file: "tenummix.nim" - line: 11 - errormsg: "type mismatch" -""" - -type - TE1 = enum eA, eB - TE2 = enum eC, eD - -assert eA != eC diff --git a/tests/reject/texprstmt.nim b/tests/reject/texprstmt.nim deleted file mode 100644 index b32394d8d..000000000 --- a/tests/reject/texprstmt.nim +++ /dev/null @@ -1,12 +0,0 @@ -discard """ - line: 10 - errormsg: "value returned by statement has to be discarded" -""" - -# bug #578 - -proc test: string = - result = "blah" - result[1 .. -1] - -echo test() diff --git a/tests/reject/tgenconstraints.nim b/tests/reject/tgenconstraints.nim deleted file mode 100644 index e32aa877b..000000000 --- a/tests/reject/tgenconstraints.nim +++ /dev/null @@ -1,30 +0,0 @@ -discard """ - file: "tgenconstraints.nim" - line: 25 - errormsg: "cannot instantiate T2" -""" - -type - T1[T: int|string] = object - x: T - - T2[T: Ordinal] = object - x: T - -var x1: T1[int] -var x2: T1[string] -var x3: T2[int] - -proc foo[T](x: T): T2[T] {.discardable.} = - var o: T1[T] - -foo(10) - -proc bar(x: string|TNumber): T1[type(x)] {.discardable.} = - when type(x) is TNumber: - var o: T2[type(x)] - -bar "test" -bar 100 -bar 1.1 - diff --git a/tests/reject/tillegaltyperecursion.nim b/tests/reject/tillegaltyperecursion.nim deleted file mode 100644 index 711f458bf..000000000 --- a/tests/reject/tillegaltyperecursion.nim +++ /dev/null @@ -1,66 +0,0 @@ -discard """ - cmd: "nimrod c --threads:on $# $#" - errormsg: "illegal recursion in type 'TIRC'" - line: 16 -""" - -import events -import sockets -import strutils -import os - -type - TMessageReceivedEventArgs = object of TEventArgs - Nick*: string - Message*: string - TIRC = object - EventEmitter: TEventEmitter - MessageReceivedHandler*: TEventHandler - Socket: TSocket - Thread: TThread[TIRC] - -proc initIRC*(): TIRC = - result.Socket = socket() - result.EventEmitter = initEventEmitter() - result.MessageReceivedHandler = initEventHandler("MessageReceived") - -proc IsConnected*(irc: var TIRC): bool = - return running(irc.Thread) - - -proc sendRaw*(irc: var TIRC, message: string) = - irc.Socket.send(message & "\r\L") -proc handleData(irc: TIRC) {.thread.} = - var connected = False - while connected: - var tup = @[irc.Socket] - var o = select(tup, 200) - echo($o) - echo($len(tup)) - if len(tup) == 1: - #Connected - connected = True - - #Parse data here - - else: - #Disconnected - connected = False - return - -proc Connect*(irc: var TIRC, nick: string, host: string, port: int = 6667) = - connect(irc.Socket ,host ,TPort(port),TDomain.AF_INET) - send(irc.Socket,"USER " & nick & " " & nick & " " & nick & " " & nick &"\r\L") - send(irc.Socket,"NICK " & nick & "\r\L") - var thread: TThread[TIRC] - createThread(thread, handleData, irc) - irc.Thread = thread - - - - -when isMainModule: - var irc = initIRC() - irc.Connect("AmryBot[Nim]","irc.freenode.net",6667) - irc.sendRaw("JOIN #nimrod") - os.Sleep(4000) diff --git a/tests/reject/tillrec.nim b/tests/reject/tillrec.nim deleted file mode 100644 index 1d1ec0622..000000000 --- a/tests/reject/tillrec.nim +++ /dev/null @@ -1,16 +0,0 @@ -discard """ - file: "tillrec.nim" - line: 13 - errormsg: "illegal recursion in type \'TIllegal\'" -""" -# test illegal recursive types - -type - TLegal {.final.} = object - x: int - kids: seq[TLegal] - - TIllegal {.final.} = object #ERROR_MSG illegal recursion in type 'TIllegal' - y: Int - x: array[0..3, TIllegal] - diff --git a/tests/reject/timportexcept.nim b/tests/reject/timportexcept.nim deleted file mode 100644 index 93a7fd642..000000000 --- a/tests/reject/timportexcept.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - line: 9 - errormsg: "undeclared identifier: '%'" -""" - -import strutils except `%` - -# doesn't work -echo "$1" % "abc" - diff --git a/tests/reject/tinc.nim b/tests/reject/tinc.nim deleted file mode 100644 index 8038a2a01..000000000 --- a/tests/reject/tinc.nim +++ /dev/null @@ -1,12 +0,0 @@ -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/tind1.nim b/tests/reject/tind1.nim deleted file mode 100644 index f3fd952cc..000000000 --- a/tests/reject/tind1.nim +++ /dev/null @@ -1,27 +0,0 @@ -discard """ - line: 24 - errormsg: "expression expected, but found 'keyword else'" -""" - -import macros - -# finally optional indentation in 'if' expressions :-): -var x = if 4 != 5: - "yes" - else: - "no" - -macro mymacro(n: expr): stmt {.immediate.} = nil - -mymacro: - echo "test" -else: - echo "else part" - - -if 4 == 3: - echo "bug" - else: - echo "no bug" - - diff --git a/tests/reject/tinout.nim b/tests/reject/tinout.nim deleted file mode 100644 index 034c496f5..000000000 --- a/tests/reject/tinout.nim +++ /dev/null @@ -1,16 +0,0 @@ -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) = - x = 0 - -proc b() = - abc(3) #ERROR - -b() - - diff --git a/tests/reject/tinvalidarrayaccess.nim b/tests/reject/tinvalidarrayaccess.nim deleted file mode 100644 index 03105b41b..000000000 --- a/tests/reject/tinvalidarrayaccess.nim +++ /dev/null @@ -1,14 +0,0 @@ -discard """ - errormsg: "index out of bounds" - line: 11 -""" - - -type TTestArr = array[0..1, int16] -var f: TTestArr -f[0] = 30 -f[1] = 40 -f[2] = 50 -f[3] = 60 - -echo(repr(f)) diff --git a/tests/reject/tinvalidborrow.nim b/tests/reject/tinvalidborrow.nim deleted file mode 100644 index 9ab9e8d64..000000000 --- a/tests/reject/tinvalidborrow.nim +++ /dev/null @@ -1,17 +0,0 @@ -discard """ - line: 11 - errormsg: "no symbol to borrow from found" -""" - -# bug #516 - -type - TAtom = culong - -proc `==`*(a, b: TAtom): bool {.borrow.} - -var - d, e: TAtom - -echo( $(d == e) ) - diff --git a/tests/reject/tinvalidclosure.nim b/tests/reject/tinvalidclosure.nim deleted file mode 100644 index c06270bfa..000000000 --- a/tests/reject/tinvalidclosure.nim +++ /dev/null @@ -1,12 +0,0 @@ -discard """ - line: 12 - errormsg: "type mismatch: got (proc (int){.closure.})" -""" - -proc ugh[T](x: T) {.closure.} = - echo "ugha" - - -proc takeCdecl(p: proc (x: int) {.cdecl.}) = nil - -takeCDecl(ugh[int]) diff --git a/tests/reject/tinvalidclosure2.nim b/tests/reject/tinvalidclosure2.nim deleted file mode 100644 index 20e465c12..000000000 --- a/tests/reject/tinvalidclosure2.nim +++ /dev/null @@ -1,14 +0,0 @@ -discard """ - line: 10 - errormsg: "illegal capture 'A'" -""" - -proc outer() = - var A: int - - proc ugh[T](x: T) {.cdecl.} = - echo "ugha", A, x - - ugh[int](12) - -outer() diff --git a/tests/reject/tinvalidnewseq.nim b/tests/reject/tinvalidnewseq.nim deleted file mode 100644 index 957a25560..000000000 --- a/tests/reject/tinvalidnewseq.nim +++ /dev/null @@ -1,27 +0,0 @@ -discard """ - file: "tinvalidnewseq.nim" - line: 15 - errormsg: "type mismatch: got (array[0..6, string], int literal(7))" -""" -import re, strutils - -type - TURL = tuple[protocol, subdomain, domain, port: string, path: seq[string]] - -proc parseURL(url: string): TURL = - #([a-zA-Z]+://)?(\w+?\.)?(\w+)(\.\w+)(:[0-9]+)?(/.+)? - var pattern: string = r"([a-zA-Z]+://)?(\w+?\.)?(\w+)(\.\w+)(:[0-9]+)?(/.+)?" - var m: array[0..6, string] #Array with the matches - newSeq(m, 7) #ERROR - discard regexprs.match(url, re(pattern), m) - - result = (protocol: m[1], subdomain: m[2], domain: m[3] & m[4], - port: m[5], path: m[6].split('/')) - -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 deleted file mode 100644 index ea8a7ddf0..000000000 --- a/tests/reject/tinvwhen.nim +++ /dev/null @@ -1,15 +0,0 @@ -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".} - -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 deleted file mode 100644 index 9b52f8055..000000000 --- a/tests/reject/titer4.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - file: "titer4.nim" - line: 7 - errormsg: "iterator within for loop context expected" -""" -# implicit items/pairs, but not if we have 3 for loop vars: -for x, y, z in {'a'..'z'}: #ERROR_MSG iterator within for loop context expected - nil - - diff --git a/tests/reject/tlet.nim b/tests/reject/tlet.nim deleted file mode 100644 index 3d36432fb..000000000 --- a/tests/reject/tlet.nim +++ /dev/null @@ -1,11 +0,0 @@ -discard """ - line: "10" - errormsg: "'name' cannot be assigned to" -""" - -Echo("What's your name? ") -let name = readLine(stdin) -while name == "": - Echo("Please tell me your name: ") - name = readLine(stdin) - diff --git a/tests/reject/tlet2.nim b/tests/reject/tlet2.nim deleted file mode 100644 index 8b1ddf940..000000000 --- a/tests/reject/tlet2.nim +++ /dev/null @@ -1,16 +0,0 @@ -discard """ - line: "13" - errormsg: "for a 'var' type a variable needs to be passed" -""" - -proc divmod(a, b: int, res, remainder: var int) = - res = a div b # integer division - remainder = a mod b # integer modulo operation - -let - x = 9 - y = 3 -divmod(8, 5, x, y) # modifies x and y -echo(x) -echo(y) - diff --git a/tests/reject/tmethod.nim b/tests/reject/tmethod.nim deleted file mode 100644 index 0cfe24c70..000000000 --- a/tests/reject/tmethod.nim +++ /dev/null @@ -1,8 +0,0 @@ -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/tmissingnl.nim b/tests/reject/tmissingnl.nim deleted file mode 100644 index 33b7debf1..000000000 --- a/tests/reject/tmissingnl.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - file: "tmissingnl.nim" - line: 7 - errormsg: "invalid indentation" -""" - -import strutils var s: seq[int] = @[0, 1, 2, 3, 4, 5, 6] - -#s[1..3] = @[] - diff --git a/tests/reject/tnamedparams.nim b/tests/reject/tnamedparams.nim deleted file mode 100644 index 9397fea4a..000000000 --- a/tests/reject/tnamedparams.nim +++ /dev/null @@ -1,15 +0,0 @@ -discard """ - file: "tnamedparams.nim" - line: 8 - errormsg: "type mismatch: got (input: string, filename: string, line: int literal(1), col: int literal(23))" -""" -import pegs - -discard parsePeg( - input = "input", - filename = "filename", - line = 1, - col = 23) - - - diff --git a/tests/reject/tnamspc.nim b/tests/reject/tnamspc.nim deleted file mode 100644 index 1e2049cec..000000000 --- a/tests/reject/tnamspc.nim +++ /dev/null @@ -1,12 +0,0 @@ -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/tneedsdiscard.nim b/tests/reject/tneedsdiscard.nim deleted file mode 100644 index 24f5b2eee..000000000 --- a/tests/reject/tneedsdiscard.nim +++ /dev/null @@ -1,12 +0,0 @@ -discard """ - line: 10 - errormsg: "value returned by statement has to be discarded" -""" - -proc p = - var f: TFile - echo "hi" - - open(f, "arg.txt") - -p() diff --git a/tests/reject/tnicerrorforsymchoice.nim b/tests/reject/tnicerrorforsymchoice.nim deleted file mode 100644 index bc271dcab..000000000 --- a/tests/reject/tnicerrorforsymchoice.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - line: 18 - errormsg: "type mismatch: got (proc (TScgi) | proc (PAsyncSocket, PStringTable, string))" -""" - -#bug #442 -import scgi, sockets, asyncio, strtabs -proc handleSCGIRequest[TScgi: TScgiState | PAsyncScgiState](s: TScgi) = - nil -proc handleSCGIRequest(client: PAsyncSocket, headers: PStringTable, - input: string) = - nil - -proc test(handle: proc (client: PAsyncSocket, headers: PStringTable, - input: string), b: int) = - nil - -test(handleSCGIRequest) diff --git a/tests/reject/tno_int_in_bool_context.nim b/tests/reject/tno_int_in_bool_context.nim deleted file mode 100644 index 755a02c0c..000000000 --- a/tests/reject/tno_int_in_bool_context.nim +++ /dev/null @@ -1,8 +0,0 @@ -discard """ - line: 6 - errormsg: "type mismatch: got (int literal(1)) but expected 'bool'" -""" - -if 1: - echo "wtf?" - diff --git a/tests/reject/tnocontains.nim b/tests/reject/tnocontains.nim deleted file mode 100644 index 4f4951478..000000000 --- a/tests/reject/tnocontains.nim +++ /dev/null @@ -1,11 +0,0 @@ -discard """ - file: "tnocontains.nim" - line: 10 - errormsg: "type mismatch: got (string, string)" -""" - -# shouldn't compile since it doesn't do what you think it does without -# importing strutils: - -let x = "abcdef".contains("abc") -echo x diff --git a/tests/reject/tnoinst.nim b/tests/reject/tnoinst.nim deleted file mode 100644 index 23a4145e0..000000000 --- a/tests/reject/tnoinst.nim +++ /dev/null @@ -1,16 +0,0 @@ -discard """ - line: 12 - errormsg: "instantiate 'notConcrete' explicitely" -""" - -proc wrap[T]() = - proc notConcrete[T](x, y: int): int = - var dummy: T - result = x - y - - var x: proc (x, y: T): int - x = notConcrete - - -wrap[int]() - diff --git a/tests/reject/tnolen.nim b/tests/reject/tnolen.nim deleted file mode 100644 index e33086536..000000000 --- a/tests/reject/tnolen.nim +++ /dev/null @@ -1,9 +0,0 @@ -discard """ - line: 8 - msg: "type mismatch: got (int literal(3))" -""" - -# please finally disallow Len(3) - -echo len(3) - diff --git a/tests/reject/tnoop.nim b/tests/reject/tnoop.nim deleted file mode 100644 index c79403e11..000000000 --- a/tests/reject/tnoop.nim +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index cd0f538e6..000000000 --- a/tests/reject/tnot.nim +++ /dev/null @@ -1,22 +0,0 @@ -discard """ - file: "tnot.nim" - line: 14 - errormsg: "type mismatch" -""" -# BUG: following compiles, but should not: - -proc nodeOfDegree(x: Int): bool = - result = false - -proc main = - for j in 0..2: - for i in 0..10: - if not nodeOfDegree(1) >= 0: #ERROR_MSG type mismatch - Echo "Yes" - else: - Echo "No" - -main() - - - diff --git a/tests/reject/tnotnil.nim b/tests/reject/tnotnil.nim deleted file mode 100644 index fba7fa917..000000000 --- a/tests/reject/tnotnil.nim +++ /dev/null @@ -1,23 +0,0 @@ -discard """ - line: 22 - errormsg: "type mismatch" -""" - -type - PObj = ref TObj not nil - TObj = object - x: int - - MyString = string not nil - -#var x: PObj = nil - -proc p(x: string not nil): int = - result = 45 - -proc q(x: MyString) = nil -proc q2(x: string) = nil - -q2(nil) -q(nil) - diff --git a/tests/reject/tnotnil1.nim b/tests/reject/tnotnil1.nim deleted file mode 100644 index 863fe45f8..000000000 --- a/tests/reject/tnotnil1.nim +++ /dev/null @@ -1,40 +0,0 @@ -discard """ - errormsg: "'y' is provably nil" - line:38 -""" - -import strutils - - -type - TObj = object - x, y: int - -type - superstring = string not nil - - -proc q(s: superstring) = - echo s - -proc p2() = - var a: string = "I am not nil" - q(a) # but this should and does not - -p2() - -proc q(x: pointer not nil) = - nil - -proc p() = - var x: pointer - if not x.isNil: - q(x) - - let y = x - if not y.isNil: - q(y) - else: - q(y) - -p() diff --git a/tests/reject/tnotnil2.nim b/tests/reject/tnotnil2.nim deleted file mode 100644 index bd6b8b675..000000000 --- a/tests/reject/tnotnil2.nim +++ /dev/null @@ -1,24 +0,0 @@ -discard """ - errormsg: "cannot prove 'y' is not nil" - line:20 -""" - -import strutils - - -type - TObj = object - x, y: int - -proc q(x: pointer not nil) = - nil - -proc p() = - var x: pointer - let y = x - if not y.isNil or y != x: - q(y) - else: - q(y) - -p() diff --git a/tests/reject/topaque.nim b/tests/reject/topaque.nim deleted file mode 100644 index f0587c959..000000000 --- a/tests/reject/topaque.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - file: "topaque.nim" - line: 16 - errormsg: "undeclared identifier: \'buffer\'" -""" -# Test the new opaque types - -import - mopaque - -var - L: TLexer - -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 deleted file mode 100644 index 0dbc5506a..000000000 --- a/tests/reject/topena1.nim +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 807b643a4..000000000 --- a/tests/reject/toverl.nim +++ /dev/null @@ -1,13 +0,0 @@ -discard """ - file: "toverl.nim" - line: 11 - errormsg: "redefinition of \'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/tprocredef.nim b/tests/reject/tprocredef.nim deleted file mode 100644 index 86ed92b62..000000000 --- a/tests/reject/tprocredef.nim +++ /dev/null @@ -1,9 +0,0 @@ -discard """ - file: "tprocredef.nim" - line: 8 - errormsg: "redefinition of \'foo\'" -""" - -proc foo(a: int, b: string) = nil -proc foo(a: int, b: string) = nil - diff --git a/tests/reject/tprocvar.nim b/tests/reject/tprocvar.nim deleted file mode 100644 index 56f76c613..000000000 --- a/tests/reject/tprocvar.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - errormsg: "type mismatch" - line: 17 - file: "tprocvar.nim" -""" - -type - TCallback = proc (a, b: int) - -proc huh(x, y: var int) = - x = 0 - y = x+1 - -proc so(c: TCallback) = - c(2, 4) - -so(huh) - diff --git a/tests/reject/trawstr.nim b/tests/reject/trawstr.nim deleted file mode 100644 index ab2aae159..000000000 --- a/tests/reject/trawstr.nim +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 73a0ec937..000000000 --- a/tests/reject/trecinca.nim +++ /dev/null @@ -1,12 +0,0 @@ -discard """ - file: "tests/reject/trecincb.nim" - line: 9 - 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 deleted file mode 100644 index 9dd7d51de..000000000 --- a/tests/reject/trecincb.nim +++ /dev/null @@ -1,13 +0,0 @@ -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 deleted file mode 100644 index dacdbdfd7..000000000 --- a/tests/reject/treciter.nim +++ /dev/null @@ -1,14 +0,0 @@ -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 = - for x in myrec(n-1): #ERROR_MSG recursive dependency: 'myrec' - yield x - -for x in myrec(10): echo x - - diff --git a/tests/reject/trecmacro.nim b/tests/reject/trecmacro.nim deleted file mode 100644 index 28b6db530..000000000 --- a/tests/reject/trecmacro.nim +++ /dev/null @@ -1,14 +0,0 @@ -discard """ - file: "trecmacro.nim" - line: 8 - errormsg: "recursive dependency: 'dump'" -""" - -macro dump(n: stmt): stmt = - dump(n) - if kind(n) == nnkNone: - nil - else: - hint($kind(n)) - for i in countUp(0, len(n)-1): - nil diff --git a/tests/reject/trectype.nim b/tests/reject/trectype.nim deleted file mode 100644 index 7bb12a3b6..000000000 --- a/tests/reject/trectype.nim +++ /dev/null @@ -1,26 +0,0 @@ -discard """ - errormsg: "internal error: cannot generate C type for: PA" -""" -# Test recursive type descriptions -# (mainly for the C code generator) - -type - PA = ref TA - TA = array [0..2, PA] - - PRec = ref TRec - TRec {.final.} = object - a, b: TA - - P1 = ref T1 - PB = ref TB - TB = array [0..3, P1] - T1 = array [0..6, PB] - -var - x: PA -new(x) -#ERROR_MSG internal error: cannot generate C type for: PA - - - diff --git a/tests/reject/trefs.nim b/tests/reject/trefs.nim deleted file mode 100644 index b157ca2b5..000000000 --- a/tests/reject/trefs.nim +++ /dev/null @@ -1,23 +0,0 @@ -discard """ - file: "trefs.nim" - line: 20 - errormsg: "type mismatch" -""" -# test for ref types (including refs to procs) - -type - TProc = proc (a, b: int): int {.stdcall.} - -proc foo(c, d: int): int {.stdcall.} = - return 0 - -proc wrongfoo(c, e: int): int {.inline.} = - return 0 - -var p: TProc -p = foo -write(stdout, "success!") -p = wrongfoo #ERROR_MSG type mismatch - - - diff --git a/tests/reject/tsidee1.nim b/tests/reject/tsidee1.nim deleted file mode 100644 index bd5b32dd7..000000000 --- a/tests/reject/tsidee1.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - file: "tsidee1.nim" - line: 12 - errormsg: "\'SideEffectLyer\' can have side effects" -""" - -var - global: int - -proc dontcare(x: int): int = return x + global - -proc SideEffectLyer(x, y: int): int {.noSideEffect.} = #ERROR_MSG 'SideEffectLyer' can have side effects - return x + y + dontcare(x) - -echo SideEffectLyer(1, 3) - - - diff --git a/tests/reject/tsidee4.nim b/tests/reject/tsidee4.nim deleted file mode 100644 index cbebfbd36..000000000 --- a/tests/reject/tsidee4.nim +++ /dev/null @@ -1,17 +0,0 @@ -discard """ - file: "tsidee4.nim" - line: 15 - errormsg: "type mismatch" -""" - -var - global: int - -proc dontcare(x: int): int = return x - -proc noSideEffect(x, y: int, p: proc (a: int): int {.noSideEffect.}): int {.noSideEffect.} = - 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 deleted file mode 100644 index dd969958c..000000000 --- a/tests/reject/tsimtych.nim +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index bf90255a0..000000000 --- a/tests/reject/tstatret.nim +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 7cbf2eb3d..000000000 --- a/tests/reject/tstmtexp.nim +++ /dev/null @@ -1,9 +0,0 @@ -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/tsubrange.nim b/tests/reject/tsubrange.nim deleted file mode 100644 index b4a333bf3..000000000 --- a/tests/reject/tsubrange.nim +++ /dev/null @@ -1,21 +0,0 @@ -discard """ - line: 20 - errormsg: "cannot convert 60 to TRange" -""" - -type - TRange = range[0..40] - -proc p(r: TRange) = - nil - -var - r: TRange - y = 50 -r = y - -p y - -const - myConst: TRange = 60 - diff --git a/tests/reject/ttempl2.nim b/tests/reject/ttempl2.nim deleted file mode 100644 index 142bbb8c7..000000000 --- a/tests/reject/ttempl2.nim +++ /dev/null @@ -1,19 +0,0 @@ -discard """ - file: "ttempl2.nim" - line: 18 - errormsg: "undeclared identifier: \'b\'" -""" -template declareInScope(x: expr, t: typeDesc): stmt {.immediate.} = - var x: t - -template declareInNewScope(x: expr, t: typeDesc): stmt {.immediate.} = - # open a new scope: - block: - var x: t - -declareInScope(a, int) -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 deleted file mode 100644 index 3e171387b..000000000 --- a/tests/reject/ttypelessemptyset.nim +++ /dev/null @@ -1,6 +0,0 @@ -discard """ - errormsg: "internal error: invalid kind for last(tyEmpty)" -""" -var q = false -discard (if q: {} else: {}) - diff --git a/tests/reject/ttypenoval.nim b/tests/reject/ttypenoval.nim deleted file mode 100644 index 214b35e29..000000000 --- a/tests/reject/ttypenoval.nim +++ /dev/null @@ -1,55 +0,0 @@ -discard """ - file: "ttypenoval.nim" - line: 38 - errormsg: "type mismatch: got (typedesc[int]) but expected 'int'" -""" - -# A min-heap. -type - TNode[T] = tuple[priority: int, data: T] - - TBinHeap[T] = object - heap: seq[TNode[T]] - last: int - - PBinHeap[T] = ref TBinHeap[T] - -proc newBinHeap*[T](heap: var PBinHeap[T], size: int) = - new(heap) - heap.last = 0 - newSeq(heap.heap, size) - #newSeq(heap.seq, size) - -proc parent(elem: int): int {.inline.} = - return (elem-1) div 2 - -proc siftUp[T](heap: PBinHeap[T], elem: int) = - var idx = elem - while idx != 0: - var p = parent(idx) - if heap.heap[idx] < heap.heap[p]: - swap(heap.heap[idx], heap.heap[p]) - idx = p - else: - break - -proc add*[T](heap: PBinHeap[T], priority: int, data: T) = - var node: TNode[T] - node.priority = int - node.data = data - heap.heap[heap.last] = node - siftUp(heap, heap.last) - inc(heap.last) - -proc print*[T](heap: PBinHeap[T]) = - for i in countup(0, heap.last): - echo($heap.heap[i]) - -var - heap: PBinHeap[int] - -newBinHeap(heap, 256) -add(heap, 1, 100) -print(heap) - - diff --git a/tests/reject/ttypenovalue.nim b/tests/reject/ttypenovalue.nim deleted file mode 100644 index b86baf8b4..000000000 --- a/tests/reject/ttypenovalue.nim +++ /dev/null @@ -1,11 +0,0 @@ -discard """ - errormsg: "value expected, but got a type" - line: 7 - disabled: true -""" - -proc crashAndBurn() = - var stuff = seq[tuple[title, body: string]] - - -crashAndBurn() diff --git a/tests/reject/tunderscores.nim b/tests/reject/tunderscores.nim deleted file mode 100644 index 8075fdae4..000000000 --- a/tests/reject/tunderscores.nim +++ /dev/null @@ -1,14 +0,0 @@ -discard """ - file: "tunderscores.nim" - line: 8 - errormsg: "invalid token: _" -""" -# Bug #502670 - -var ef_ = 3 #ERROR_MSG invalid token: _ -var a__b = 1 -var c___d = 2 -echo(ab, cd, ef_) - - - diff --git a/tests/reject/tuninit1.nim b/tests/reject/tuninit1.nim deleted file mode 100644 index 2a994b187..000000000 --- a/tests/reject/tuninit1.nim +++ /dev/null @@ -1,36 +0,0 @@ -discard """ - errormsg: "'y' might not have been initialized" - line:34 -""" - -import strutils - -{.warning[Uninit]:on.} - -proc p = - var x, y, z: int - if stdin.readLine == "true": - x = 34 - - while false: - y = 999 - break - - while true: - if x == 12: break - y = 9999 - - try: - z = parseInt("1233") - except E_Base: - case x - of 34: z = 123 - of 13: z = 34 - else: z = 8 - else: - y = 3444 - x = 3111 - z = 0 - echo x, y, z - -p() diff --git a/tests/reject/tvarres1.nim b/tests/reject/tvarres1.nim deleted file mode 100644 index de4a505d3..000000000 --- a/tests/reject/tvarres1.nim +++ /dev/null @@ -1,17 +0,0 @@ -discard """ - file: "tvarres1.nim" - line: 12 - errormsg: "address of 'bla' may not escape its stack frame" -""" - -var - g = 5 - -proc p(): var int = - var bla: int - result = bla - -p() = 45 - -echo g - diff --git a/tests/reject/tvarres2.nim b/tests/reject/tvarres2.nim deleted file mode 100644 index 165e4a36e..000000000 --- a/tests/reject/tvarres2.nim +++ /dev/null @@ -1,16 +0,0 @@ -discard """ - file: "tvarres2.nim" - line: 11 - errormsg: "expression has no address" -""" - -var - g = 5 - -proc p(): var int = - result = 89 - -p() = 45 - -echo g - diff --git a/tests/reject/twrongconst.nim b/tests/reject/twrongconst.nim deleted file mode 100644 index e5b8a15bd..000000000 --- a/tests/reject/twrongconst.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - output: "Error: cannot evaluate at compile time: x" - line: 10 -""" - -var x: array[100, char] -template Foo : expr = x[42] - - -const myConst = foo diff --git a/tests/reject/twrongiter.nim b/tests/reject/twrongiter.nim deleted file mode 100644 index 33394219b..000000000 --- a/tests/reject/twrongiter.nim +++ /dev/null @@ -1,13 +0,0 @@ -discard """ -line: 12 -errormsg: "type mismatch" -""" - -proc first(it: iterator(): int): seq[int] = - return @[] - -iterator primes(): int = - yield 1 - -for i in first(primes): - break diff --git a/tests/reject/twrongtupleaccess.nim b/tests/reject/twrongtupleaccess.nim deleted file mode 100644 index 1a9ae64a2..000000000 --- a/tests/reject/twrongtupleaccess.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - file: "twrongtupleaccess.nim" - line: 9 - errormsg: "undeclared identifier: \'setBLAH\'" -""" -# Bugfix - -var v = (5.0, 10.0) -v.setBLAH(10) - diff --git a/tests/reject/typredef.nim b/tests/reject/typredef.nim deleted file mode 100644 index 0b6aed875..000000000 --- a/tests/reject/typredef.nim +++ /dev/null @@ -1,8 +0,0 @@ -discard """ - file: "typredef.nim" - line: 7 - errormsg: "illegal recursion in type \'Uint8\'" -""" -type - Uint8 = Uint8 #ERROR_MSG illegal recursion in type 'Uint8' - |