diff options
Diffstat (limited to 'tests/reject')
68 files changed, 0 insertions, 1068 deletions
diff --git a/tests/reject/99bottles.nim b/tests/reject/99bottles.nim deleted file mode 100755 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 100755 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 100755 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/mbind4.nim b/tests/reject/mbind4.nim deleted file mode 100755 index 53b8331cd..000000000 --- a/tests/reject/mbind4.nim +++ /dev/null @@ -1,9 +0,0 @@ -# Module A -var - lastId = 0 - -template genId*: expr = - inc(lastId) - lastId - - diff --git a/tests/reject/mnamspc1.nim b/tests/reject/mnamspc1.nim deleted file mode 100755 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 100755 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 100755 index b7c5180fd..000000000 --- a/tests/reject/mopaque.nim +++ /dev/null @@ -1,5 +0,0 @@ -type - TLexer* {.final.} = object - line*: int - filename*: string - buffer: cstring diff --git a/tests/reject/t99bott.nim b/tests/reject/t99bott.nim deleted file mode 100755 index 7ebfd61e9..000000000 --- a/tests/reject/t99bott.nim +++ /dev/null @@ -1,36 +0,0 @@ -discard """ - file: "t99bott.nim" - line: 26 - errormsg: "constant expression expected" - 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 dbfa42f18..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 100755 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 100755 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 100755 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 100755 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/tatomic.nim b/tests/reject/tatomic.nim deleted file mode 100755 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 100755 index 72a9844bb..000000000 --- a/tests/reject/tbind2.nim +++ /dev/null @@ -1,17 +0,0 @@ -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 -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/tbind4.nim b/tests/reject/tbind4.nim deleted file mode 100755 index a0ba88e7c..000000000 --- a/tests/reject/tbind4.nim +++ /dev/null @@ -1,13 +0,0 @@ -discard """ - file: "mbind4.nim" - line: 6 - errormsg: "undeclared identifier: \'lastId\'" -""" -# Module B -import mbind4 - -echo genId() - - - - diff --git a/tests/reject/tblock1.nim b/tests/reject/tblock1.nim deleted file mode 100755 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/tconstr1.nim b/tests/reject/tconstr1.nim deleted file mode 100755 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 100755 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 100755 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/temptycaseobj.nim b/tests/reject/temptycaseobj.nim deleted file mode 100755 index 5977cb92b..000000000 --- a/tests/reject/temptycaseobj.nim +++ /dev/null @@ -1,14 +0,0 @@ -discard """ - line: 11 - errormsg: "identifier expected, but found '[same indentation]'" -""" - -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 5fcd0ef22..000000000 --- a/tests/reject/tenummix.nim +++ /dev/null @@ -1,11 +0,0 @@ -discard """ - file: "system.nim" - line: 641 - errormsg: "type mismatch" -""" - -type - TE1 = enum eA, eB - TE2 = enum eC, eD - -assert eA != eC 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 100755 index 3f8fe60fc..000000000 --- a/tests/reject/tillrec.nim +++ /dev/null @@ -1,17 +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/tinc.nim b/tests/reject/tinc.nim deleted file mode 100755 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 e14de09ce..000000000 --- a/tests/reject/tind1.nim +++ /dev/null @@ -1,27 +0,0 @@ -discard """ - line: 24 - errormsg: "invalid indentation" -""" - -import macros - -# finally optional indentation in 'if' expressions :-): -var x = if 4 != 5: - "yes" - else: - "no" - -macro mymacro(n: expr): expr = result = n[1][0] - -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 100755 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/tinvalidclosure.nim b/tests/reject/tinvalidclosure.nim deleted file mode 100644 index f5ac3a5f0..000000000 --- a/tests/reject/tinvalidclosure.nim +++ /dev/null @@ -1,7 +0,0 @@ -discard """ - line: 6 - errormsg: "'ugh' cannot have 'closure' calling convention" -""" - -proc ugh[T](x: T) {.closure.} = - echo "ugha" diff --git a/tests/reject/tinvalidnewseq.nim b/tests/reject/tinvalidnewseq.nim deleted file mode 100755 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 100755 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 100755 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 100755 index 999016072..000000000 --- a/tests/reject/tmethod.nim +++ /dev/null @@ -1,11 +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 c2f97a807..000000000 --- a/tests/reject/tmissingnl.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - file: "tmissingnl.nim" - line: 7 - errormsg: "newline expected, but found 'keyword var'" -""" - -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 100755 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 100755 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/tno_int_in_bool_context.nim b/tests/reject/tno_int_in_bool_context.nim deleted file mode 100755 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/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 100755 index 2d320c849..000000000 --- a/tests/reject/tnoop.nim +++ /dev/null @@ -1,13 +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 100755 index 1985ef666..000000000 --- a/tests/reject/tnot.nim +++ /dev/null @@ -1,21 +0,0 @@ -discard """ - file: "system.nim" - 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/topaque.nim b/tests/reject/topaque.nim deleted file mode 100755 index ac390835b..000000000 --- a/tests/reject/topaque.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - file: "topaque.nim" - line: 16 - errormsg: "undeclared field: \'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 100755 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 100755 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 100755 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 100755 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 100755 index cf2f7df0c..000000000 --- a/tests/reject/trecinca.nim +++ /dev/null @@ -1,12 +0,0 @@ -discard """ - file: "trecincb.nim" - line: 9 - errormsg: "recursive dependency: '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 100755 index eb0f72db0..000000000 --- a/tests/reject/trecincb.nim +++ /dev/null @@ -1,13 +0,0 @@ -discard """ - file: "trecincb.nim" - line: 9 - errormsg: "recursive dependency: '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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 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 100755 index 50248ad32..000000000 --- a/tests/reject/tstmtexp.nim +++ /dev/null @@ -1,10 +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/ttempl2.nim b/tests/reject/ttempl2.nim deleted file mode 100755 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 100755 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 100755 index 6362407ef..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/tunderscores.nim b/tests/reject/tunderscores.nim deleted file mode 100755 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/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/twrongtupleaccess.nim b/tests/reject/twrongtupleaccess.nim deleted file mode 100755 index bb09b108d..000000000 --- a/tests/reject/twrongtupleaccess.nim +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100755 index b2182d116..000000000 --- a/tests/reject/typredef.nim +++ /dev/null @@ -1,10 +0,0 @@ -discard """ - file: "typredef.nim" - line: 7 - errormsg: "illegal recursion in type \'Uint8\'" -""" -type - Uint8 = Uint8 #ERROR_MSG illegal recursion in type 'Uint8' - - - |