diff options
Diffstat (limited to 'tests')
144 files changed, 1021 insertions, 556 deletions
diff --git a/tests/actiontable/tactiontable2.nim b/tests/actiontable/tactiontable2.nim index bfeb1c169..99bb3dca0 100644 --- a/tests/actiontable/tactiontable2.nim +++ b/tests/actiontable/tactiontable2.nim @@ -1,6 +1,6 @@ discard """ line: 21 - errormsg: "invalid type: 'TTable[string, proc (string){.gcsafe.}]'" + errormsg: "invalid type: 'Table[string, proc (string){.gcsafe.}]'" """ import tables diff --git a/tests/assert/tassert.nim b/tests/assert/tassert.nim index 0ea8d2034..b3df30bd1 100644 --- a/tests/assert/tassert.nim +++ b/tests/assert/tassert.nim @@ -5,7 +5,7 @@ discard """ """ # test assert and exception handling -proc callB() = assert(False) +proc callB() = assert(false) proc callA() = callB() proc callC() = callA() diff --git a/tests/async/tasyncawait.nim b/tests/async/tasyncawait.nim index 2d65db4bd..5165b0f06 100644 --- a/tests/async/tasyncawait.nim +++ b/tests/async/tasyncawait.nim @@ -21,15 +21,8 @@ proc launchSwarm(port: TPort) {.async.} = var sock = newAsyncRawSocket() await connect(sock, "localhost", port) - when true: - await sendMessages(sock) - closeSocket(sock) - else: - # Issue #932: https://github.com/Araq/Nimrod/issues/932 - var msgFut = sendMessages(sock) - msgFut.callback = - proc () = - closeSocket(sock) + await sendMessages(sock) + closeSocket(sock) proc readMessages(client: TAsyncFD) {.async.} = while true: @@ -47,18 +40,18 @@ proc readMessages(client: TAsyncFD) {.async.} = proc createServer(port: TPort) {.async.} = var server = newAsyncRawSocket() block: - var name: TSockaddr_in + var name: Sockaddr_in when defined(windows): name.sin_family = toInt(AF_INET).int16 else: name.sin_family = toInt(AF_INET) name.sin_port = htons(int16(port)) name.sin_addr.s_addr = htonl(INADDR_ANY) - if bindAddr(server.TSocketHandle, cast[ptr TSockAddr](addr(name)), - sizeof(name).TSocklen) < 0'i32: - osError(osLastError()) + if bindAddr(server.SocketHandle, cast[ptr SockAddr](addr(name)), + sizeof(name).Socklen) < 0'i32: + raiseOSError(osLastError()) - discard server.TSocketHandle.listen() + discard server.SocketHandle.listen() while true: var client = await accept(server) asyncCheck readMessages(client) diff --git a/tests/async/tasyncdiscard.nim b/tests/async/tasyncdiscard.nim index 966851acc..71aba29e2 100644 --- a/tests/async/tasyncdiscard.nim +++ b/tests/async/tasyncdiscard.nim @@ -13,7 +13,7 @@ discard """ import asyncio, asyncdispatch, asyncnet proc main {.async.} = - proc f: PFuture[int] {.async.} = + proc f: Future[int] {.async.} = discard echo 1 discard @@ -24,7 +24,7 @@ proc main {.async.} = echo x echo 3 - proc g: PFuture[int] {.async.} = + proc g: Future[int] {.async.} = discard echo 4 discard diff --git a/tests/async/tasyncexceptions.nim b/tests/async/tasyncexceptions.nim index ca73c6a3d..30ef41756 100644 --- a/tests/async/tasyncexceptions.nim +++ b/tests/async/tasyncexceptions.nim @@ -1,15 +1,15 @@ discard """ file: "tasyncexceptions.nim" exitcode: 1 - outputsub: "Error: unhandled exception: foobar [E_Base]" + outputsub: "Error: unhandled exception: foobar [Exception]" """ import asyncdispatch -proc accept(): PFuture[int] {.async.} = +proc accept(): Future[int] {.async.} = await sleepAsync(100) result = 4 -proc recvLine(fd: int): PFuture[string] {.async.} = +proc recvLine(fd: int): Future[string] {.async.} = await sleepAsync(100) return "get" diff --git a/tests/async/tasyncfile.nim b/tests/async/tasyncfile.nim new file mode 100644 index 000000000..c3cf33512 --- /dev/null +++ b/tests/async/tasyncfile.nim @@ -0,0 +1,36 @@ +discard """ + file: "tasyncfile.nim" + exitcode: 0 +""" +import asyncfile, asyncdispatch, os + +proc main() {.async.} = + let fn = getTempDir() / "foobar.txt" + removeFile(fn) + + # Simple write/read test. + block: + var file = openAsync(fn, fmReadWrite) + await file.write("test") + file.setFilePos(0) + await file.write("foo") + file.setFilePos(0) + let data = await file.readAll() + doAssert data == "foot" + file.close() + + # Append test + block: + var file = openAsync(fn, fmAppend) + await file.write("\ntest2") + let errorTest = file.readAll() + await errorTest + doAssert errorTest.failed + file.close() + file = openAsync(fn, fmRead) + let data = await file.readAll() + + doAssert data == "foot\ntest2" + file.close() + +waitFor main() diff --git a/tests/async/tasynciossl.nim b/tests/async/tasynciossl.nim index 6b38fcf7b..b0222e4ff 100644 --- a/tests/async/tasynciossl.nim +++ b/tests/async/tasynciossl.nim @@ -1,6 +1,6 @@ discard """ file: "tasynciossl.nim" - cmd: "nimrod $target --hints:on --define:ssl $options $file" + cmd: "nim $target --hints:on --define:ssl $options $file" output: "20000" """ import sockets, asyncio, strutils, times diff --git a/tests/async/tasynctry.nim b/tests/async/tasynctry.nim new file mode 100644 index 000000000..66ea40d49 --- /dev/null +++ b/tests/async/tasynctry.nim @@ -0,0 +1,51 @@ +discard """ + file: "tasynctry.nim" + exitcode: 0 + output: ''' +Generic except: Test +Specific except +Multiple idents in except +Multiple except branches +Multiple except branches 2 +''' +""" +import asyncdispatch + +# Here we are testing the ability to catch exceptions. + +proc foobar() {.async.} = + if 5 == 5: + raise newException(EInvalidIndex, "Test") + +proc catch() {.async.} = + # TODO: Create a test for when exceptions are not caught. + try: + await foobar() + except: + echo("Generic except: ", getCurrentExceptionMsg()) + + try: + await foobar() + except EInvalidIndex: + echo("Specific except") + + try: + await foobar() + except OSError, EInvalidField, EInvalidIndex: + echo("Multiple idents in except") + + try: + await foobar() + except OSError, EInvalidField: + assert false + except EInvalidIndex: + echo("Multiple except branches") + + try: + await foobar() + except EInvalidIndex: + echo("Multiple except branches 2") + except OSError, EInvalidField: + assert false + +asyncCheck catch() diff --git a/tests/async/tnestedpfuturetypeparam.nim b/tests/async/tnestedpfuturetypeparam.nim index 1db442170..bf346ff8e 100644 --- a/tests/async/tnestedpfuturetypeparam.nim +++ b/tests/async/tnestedpfuturetypeparam.nim @@ -1,8 +1,8 @@ import asyncdispatch, asyncnet proc main {.async.} = - proc f: PFuture[seq[int]] {.async.} = - await newAsyncSocket().connect("www.google.com", TPort(80)) + proc f: Future[seq[int]] {.async.} = + await newAsyncSocket().connect("www.google.com", Port(80)) let x = await f() asyncCheck main() diff --git a/tests/benchmark.nim b/tests/benchmark.nim index 8dd9cc2e2..0613d1bf9 100644 --- a/tests/benchmark.nim +++ b/tests/benchmark.nim @@ -1,6 +1,6 @@ # # -# Nimrod Benchmark tool +# Nim Benchmark tool # (c) Copyright 2012 Dominik Picheta # # See the file "copying.txt", included in this @@ -15,7 +15,7 @@ type proc compileBench(file: string) = ## Compiles ``file``. - doAssert(execCmdEx("nimrod c -d:release " & file).exitCode == QuitSuccess) + doAssert(execCmdEx("nim c -d:release " & file).exitCode == QuitSuccess) proc runBench(file: string): TBenchResult = ## Runs ``file`` and returns info on how long it took to run. diff --git a/tests/bind/tnicerrorforsymchoice.nim b/tests/bind/tnicerrorforsymchoice.nim index 4e7a271b3..e1ff090dd 100644 --- a/tests/bind/tnicerrorforsymchoice.nim +++ b/tests/bind/tnicerrorforsymchoice.nim @@ -1,17 +1,17 @@ discard """ line: 18 - errormsg: "type mismatch: got (proc (TScgi) | proc (PAsyncSocket, PStringTable, string){.gcsafe.})" + errormsg: "type mismatch: got (proc (TScgi) | proc (AsyncSocket, StringTableRef, string){.gcsafe.})" """ #bug #442 import scgi, sockets, asyncio, strtabs -proc handleSCGIRequest[TScgi: TScgiState | PAsyncScgiState](s: TScgi) = +proc handleSCGIRequest[TScgi: ScgiState | AsyncScgiState](s: TScgi) = discard -proc handleSCGIRequest(client: PAsyncSocket, headers: PStringTable, +proc handleSCGIRequest(client: AsyncSocket, headers: StringTableRef, input: string) = discard -proc test(handle: proc (client: PAsyncSocket, headers: PStringTable, +proc test(handle: proc (client: AsyncSocket, headers: StringTableRef, input: string), b: int) = discard diff --git a/tests/borrow/tborrow.nim b/tests/borrow/tborrow.nim index 8e6aeba74..d4df5f524 100644 --- a/tests/borrow/tborrow.nim +++ b/tests/borrow/tborrow.nim @@ -18,4 +18,4 @@ proc `++`(x, y: DF): DF {.borrow.} proc `$`(x: DI): string {.borrow.} proc `$`(x: DF): string {.borrow.} -echo 4544.DI ++ 343.di, " ", (4.5.df ++ 0.5.df).float == 5.0 +echo 4544.DI ++ 343.DI, " ", (4.5.DF ++ 0.5.DF).float == 5.0 diff --git a/tests/casestmt/tcasestm.nim b/tests/casestmt/tcasestm.nim index b033b98ec..a21b6be0d 100644 --- a/tests/casestmt/tcasestm.nim +++ b/tests/casestmt/tcasestm.nim @@ -5,7 +5,7 @@ discard """ # Test the case statement type - tenum = enum eA, eB, eC + Tenum = enum eA, eB, eC var x: string = "yyy" diff --git a/tests/ccgbugs/tccgen1.nim b/tests/ccgbugs/tccgen1.nim index 137dd545d..9234bbd6c 100644 --- a/tests/ccgbugs/tccgen1.nim +++ b/tests/ccgbugs/tccgen1.nim @@ -45,7 +45,7 @@ type PText* = ref Text Text = object of CharacterData - PComment* = ref comment + PComment* = ref Comment Comment = object of CharacterData PCDataSection* = ref CDataSection diff --git a/tests/ccgbugs/tcodegenbug1.nim b/tests/ccgbugs/tcodegenbug1.nim index 7d0fc4ad5..9b9771485 100644 --- a/tests/ccgbugs/tcodegenbug1.nim +++ b/tests/ccgbugs/tcodegenbug1.nim @@ -51,7 +51,7 @@ proc `$`*(status: TStatusEnum): string = return "unknown" proc makeCommitPath*(platform, hash: string): string = - return platform / "nimrod_" & hash.substr(0, 11) # 11 Chars. + return platform / "nim_" & hash.substr(0, 11) # 11 Chars. type TFlag = enum diff --git a/tests/clearmsg/mb.nim b/tests/clearmsg/mb.nim new file mode 100644 index 000000000..2d21e2396 --- /dev/null +++ b/tests/clearmsg/mb.nim @@ -0,0 +1,2 @@ +type + typ* = distinct string diff --git a/tests/clearmsg/mc.nim b/tests/clearmsg/mc.nim new file mode 100644 index 000000000..79d7431df --- /dev/null +++ b/tests/clearmsg/mc.nim @@ -0,0 +1,3 @@ + +type + typ* = distinct int diff --git a/tests/clearmsg/ta.nim b/tests/clearmsg/ta.nim new file mode 100644 index 000000000..b21522d12 --- /dev/null +++ b/tests/clearmsg/ta.nim @@ -0,0 +1,12 @@ +discard """ + errormsg: 'type mismatch: got (mc.typ)' + line: 12 +""" + +import mb, mc + +proc test(testing: mb.typ) = + discard + +var s: mc.typ +test(s) diff --git a/tests/closure/tclosure.nim b/tests/closure/tclosure.nim index 764aaa97d..445a99b6d 100644 --- a/tests/closure/tclosure.nim +++ b/tests/closure/tclosure.nim @@ -36,7 +36,7 @@ myData.each do (x: int): type ITest = tuple[ - setter: proc(v: Int), + setter: proc(v: int), getter: proc(): int] proc getInterf(): ITest = diff --git a/tests/closure/tclosurebug2.nim b/tests/closure/tclosurebug2.nim index ec4f0045b..12e4e3509 100644 --- a/tests/closure/tclosurebug2.nim +++ b/tests/closure/tclosurebug2.nim @@ -38,17 +38,17 @@ template rawInsertImpl() {.dirty.} = data[h].val = val data[h].slot = seFilled -template AddImpl() {.dirty.} = - if mustRehash(len(t.data), t.counter): Enlarge(t) - RawInsert(t, t.data, key, val) +template addImpl() {.dirty.} = + if mustRehash(len(t.data), t.counter): enlarge(t) + rawInsert(t, t.data, key, val) inc(t.counter) -template PutImpl() {.dirty.} = - var index = RawGet(t, key) +template putImpl() {.dirty.} = + var index = rawGet(t, key) if index >= 0: t.data[index].val = val else: - AddImpl() + addImpl() proc len*[A, B](t: TOrderedTable[A, B]): int {.inline.} = ## returns the number of keys in `t`. @@ -89,7 +89,7 @@ iterator mvalues*[A, B](t: var TOrderedTable[A, B]): var B = forAllOrderedPairs: yield t.data[h].val -proc RawGet[A, B](t: TOrderedTable[A, B], key: A): int = +proc rawGet[A, B](t: TOrderedTable[A, B], key: A): int = rawGetImpl() proc `[]`*[A, B](t: TOrderedTable[A, B], key: A): B = @@ -97,21 +97,21 @@ proc `[]`*[A, B](t: TOrderedTable[A, B], key: A): B = ## default empty value for the type `B` is returned ## and no exception is raised. One can check with ``hasKey`` whether the key ## exists. - var index = RawGet(t, key) + var index = rawGet(t, key) if index >= 0: result = t.data[index].val proc mget*[A, B](t: var TOrderedTable[A, B], key: A): var B = ## retrieves the value at ``t[key]``. The value can be modified. ## If `key` is not in `t`, the ``EInvalidKey`` exception is raised. - var index = RawGet(t, key) + var index = rawGet(t, key) if index >= 0: result = t.data[index].val - else: raise newException(EInvalidKey, "key not found: " & $key) + else: raise newException(KeyError, "key not found: " & $key) proc hasKey*[A, B](t: TOrderedTable[A, B], key: A): bool = ## returns true iff `key` is in the table `t`. result = rawGet(t, key) >= 0 -proc RawInsert[A, B](t: var TOrderedTable[A, B], +proc rawInsert[A, B](t: var TOrderedTable[A, B], data: var TOrderedKeyValuePairSeq[A, B], key: A, val: B) = rawInsertImpl() @@ -120,7 +120,7 @@ proc RawInsert[A, B](t: var TOrderedTable[A, B], if t.last >= 0: data[t.last].next = h t.last = h -proc Enlarge[A, B](t: var TOrderedTable[A, B]) = +proc enlarge[A, B](t: var TOrderedTable[A, B]) = var n: TOrderedKeyValuePairSeq[A, B] newSeq(n, len(t.data) * growthFactor) var h = t.first @@ -129,7 +129,7 @@ proc Enlarge[A, B](t: var TOrderedTable[A, B]) = while h >= 0: var nxt = t.data[h].next if t.data[h].slot == seFilled: - RawInsert(t, n, t.data[h].key, t.data[h].val) + rawInsert(t, n, t.data[h].key, t.data[h].val) h = nxt swap(t.data, n) @@ -139,7 +139,7 @@ proc `[]=`*[A, B](t: var TOrderedTable[A, B], key: A, val: B) = proc add*[A, B](t: var TOrderedTable[A, B], key: A, val: B) = ## puts a new (key, value)-pair into `t` even if ``t[key]`` already exists. - AddImpl() + addImpl() proc initOrderedTable*[A, B](initialSize=64): TOrderedTable[A, B] = ## creates a new ordered hash table that is empty. `initialSize` needs to be diff --git a/tests/concurrency/tnodeadlocks.nim b/tests/concurrency/tnodeadlocks.nim index d44196039..7a3eedbc2 100644 --- a/tests/concurrency/tnodeadlocks.nim +++ b/tests/concurrency/tnodeadlocks.nim @@ -1,6 +1,6 @@ discard """ outputsub: "101" - cmd: "nimrod $target --hints:on --threads:on $options $file" + cmd: "nim $target --hints:on --threads:on $options $file" """ import os, locks @@ -20,46 +20,46 @@ proc threadFunc(interval: tuple[a, b: int]) {.thread.} = when nodeadlocks: case i mod 6 of 0: - Acquire(L) # lock stdout - Acquire(M) - Acquire(N) + acquire(L) # lock stdout + acquire(M) + acquire(N) of 1: - Acquire(L) - Acquire(N) # lock stdout - Acquire(M) + acquire(L) + acquire(N) # lock stdout + acquire(M) of 2: - Acquire(M) - Acquire(L) - Acquire(N) + acquire(M) + acquire(L) + acquire(N) of 3: - Acquire(M) - Acquire(N) - Acquire(L) + acquire(M) + acquire(N) + acquire(L) of 4: - Acquire(N) - Acquire(M) - Acquire(L) + acquire(N) + acquire(M) + acquire(L) of 5: - Acquire(N) - Acquire(L) - Acquire(M) + acquire(N) + acquire(L) + acquire(M) else: assert false else: - Acquire(L) # lock stdout - Acquire(M) + acquire(L) # lock stdout + acquire(M) echo i os.sleep(10) when nodeadlocks: echo "deadlocks prevented: ", deadlocksPrevented when nodeadlocks: - Release(N) - Release(M) - Release(L) + release(N) + release(M) + release(L) -InitLock(L) -InitLock(M) -InitLock(N) +initLock(L) +initLock(M) +initLock(N) proc main = for i in 0..high(thr): diff --git a/tests/constr/tconstr1.nim b/tests/constr/tconstr1.nim index cb6594213..45e303554 100644 --- a/tests/constr/tconstr1.nim +++ b/tests/constr/tconstr1.nim @@ -10,7 +10,7 @@ type s: string, x, y: int, z: float, - chars: set[Char]] + chars: set[char]] proc testSem = var diff --git a/tests/destructor/tdictdestruct.nim b/tests/destructor/tdictdestruct.nim index b7043f7b7..17ded4853 100644 --- a/tests/destructor/tdictdestruct.nim +++ b/tests/destructor/tdictdestruct.nim @@ -11,7 +11,7 @@ proc fakeNew[T](x: var ref T, destroy: proc (a: ref T) {.nimcall.}) = proc destroyDict[TK, TV](a: PDict[TK, TV]) = return proc newDict[TK, TV](a: TK, b: TV): PDict[TK, TV] = - Fakenew(result, destroyDict[TK, TV]) + fakeNew(result, destroyDict[TK, TV]) # Problem: destroyDict is not instantiated when newDict is instantiated! diff --git a/tests/dll/client.nim b/tests/dll/client.nim index 45fa8f639..d535e8750 100644 --- a/tests/dll/client.nim +++ b/tests/dll/client.nim @@ -1,6 +1,6 @@ discard """ output: "Done" - cmd: "nimrod $target --debuginfo --hints:on --define:useNimRtl $options $file" + cmd: "nim $target --debuginfo --hints:on --define:useNimRtl $options $file" """ type diff --git a/tests/dll/server.nim b/tests/dll/server.nim index b2fac9ecc..df3223444 100644 --- a/tests/dll/server.nim +++ b/tests/dll/server.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nimrod $target --debuginfo --hints:on --define:useNimRtl --app:lib $options $file" + cmd: "nim $target --debuginfo --hints:on --define:useNimRtl --app:lib $options $file" """ type diff --git a/tests/effects/teffects1.nim b/tests/effects/teffects1.nim index f73230ff9..e32096b57 100644 --- a/tests/effects/teffects1.nim +++ b/tests/effects/teffects1.nim @@ -1,7 +1,7 @@ discard """ - line: 2136 + line: 2170 file: "system.nim" - errormsg: "can raise an unlisted exception: ref EIO" + errormsg: "can raise an unlisted exception: ref IOError" """ type @@ -9,13 +9,13 @@ type TObjB = object of TObj a, b, c: string - EIO2 = ref object of EIO + IO2Error = ref object of IOError proc forw: int {. .} -proc lier(): int {.raises: [EIO2].} = +proc lier(): int {.raises: [IO2Error].} = writeln stdout, "arg" proc forw: int = - raise newException(EIO, "arg") + raise newException(IOError, "arg") diff --git a/tests/effects/teffects2.nim b/tests/effects/teffects2.nim index 7e6b17c36..89ad16edc 100644 --- a/tests/effects/teffects2.nim +++ b/tests/effects/teffects2.nim @@ -1,6 +1,6 @@ discard """ line: 19 - errormsg: "can raise an unlisted exception: ref EIO" + errormsg: "can raise an unlisted exception: ref IOError" """ type @@ -8,13 +8,13 @@ type TObjB = object of TObj a, b, c: string - EIO2 = ref object of EIO + EIO2 = ref object of IOError proc forw: int {.raises: [].} -proc lier(): int {.raises: [EIO].} = +proc lier(): int {.raises: [IOError].} = writeln stdout, "arg" proc forw: int = - raise newException(EIO, "arg") + raise newException(IOError, "arg") diff --git a/tests/effects/tgcsafe.nim b/tests/effects/tgcsafe.nim index 87388238a..0d5109439 100644 --- a/tests/effects/tgcsafe.nim +++ b/tests/effects/tgcsafe.nim @@ -1,6 +1,7 @@ discard """ - line: 15 + line: 16 errormsg: "'mainUnsafe' is not GC-safe" + cmd: "nim $target --hints:on --threads:on $options $file" """ proc mymap(x: proc ()) = diff --git a/tests/exception/texcpt1.nim b/tests/exception/texcpt1.nim index ec74c9470..50a95eeec 100644 --- a/tests/exception/texcpt1.nim +++ b/tests/exception/texcpt1.nim @@ -2,8 +2,8 @@ discard """ outputsub: "-6" """ type - ESomething = object of E_Base - ESomeOtherErr = object of E_Base + ESomething = object of Exception + ESomeOtherErr = object of Exception proc genErrors(s: string) = if s == "error!": diff --git a/tests/exception/tnestedreturn.nim b/tests/exception/tnestedreturn.nim index b9f7843f6..591638f0e 100644 --- a/tests/exception/tnestedreturn.nim +++ b/tests/exception/tnestedreturn.nim @@ -10,8 +10,8 @@ proc test1() = finally: echo "A" try: - raise newException(EOS, "Problem") - except EOS: + raise newException(OSError, "Problem") + except OSError: return test1() @@ -23,7 +23,7 @@ proc test2() = try: return - except EOS: + except OSError: discard test2() @@ -31,8 +31,8 @@ test2() proc test3() = try: try: - raise newException(EOS, "Problem") - except EOS: + raise newException(OSError, "Problem") + except OSError: return finally: echo "C" diff --git a/tests/exception/tnestedreturn2.nim b/tests/exception/tnestedreturn2.nim index 14a2dab92..4bd2d535d 100644 --- a/tests/exception/tnestedreturn2.nim +++ b/tests/exception/tnestedreturn2.nim @@ -1,14 +1,14 @@ discard """ - file: "tnestedreturn.nim" - outputsub: "Error: unhandled exception: Problem [EOS]" + file: "tnestedreturn2.nim" + outputsub: "Error: unhandled exception: Problem [OSError]" exitcode: "1" """ proc test4() = try: try: - raise newException(EOS, "Problem") - except EOS: + raise newException(OSError, "Problem") + except OSError: return finally: discard @@ -17,4 +17,4 @@ proc test4() = # but could cause segmentation fault if # exceptions are not handled properly. test4() -raise newException(EOS, "Problem") +raise newException(OSError, "Problem") diff --git a/tests/exception/tunhandledexc.nim b/tests/exception/tunhandledexc.nim index f24881aef..aa9d61236 100644 --- a/tests/exception/tunhandledexc.nim +++ b/tests/exception/tunhandledexc.nim @@ -4,8 +4,8 @@ discard """ exitcode: "1" """ type - ESomething = object of E_Base - ESomeOtherErr = object of E_Base + ESomething = object of Exception + ESomeOtherErr = object of Exception proc genErrors(s: string) = if s == "error!": @@ -13,7 +13,7 @@ proc genErrors(s: string) = else: raise newException(EsomeotherErr, "bla") -when True: +when true: try: genErrors("errssor!") except ESomething: diff --git a/tests/exception/twrongexc.nim b/tests/exception/twrongexc.nim index 755f7d979..4e921b8a3 100644 --- a/tests/exception/twrongexc.nim +++ b/tests/exception/twrongexc.nim @@ -1,11 +1,11 @@ discard """ file: "twrongexc.nim" - outputsub: "Error: unhandled exception: [EInvalidValue]" + outputsub: "Error: unhandled exception: [ValueError]" exitcode: "1" """ try: - raise newException(EInvalidValue, "") -except EOverflow: + raise newException(ValueError, "") +except OverflowError: echo("Error caught") diff --git a/tests/float/tfloat1.nim b/tests/float/tfloat1.nim index f290fdb57..ed99260ea 100644 --- a/tests/float/tfloat1.nim +++ b/tests/float/tfloat1.nim @@ -1,6 +1,6 @@ discard """ file: "tfloat1.nim" - outputsub: "Error: unhandled exception: FPU operation caused an overflow [EFloatOverflow]" + outputsub: "Error: unhandled exception: FPU operation caused an overflow [FloatOverflowError]" exitcode: "1" """ # Test new floating point exceptions @@ -10,6 +10,6 @@ discard """ var x = 0.8 var y = 0.0 -echo x / y #OUT Error: unhandled exception: FPU operation caused an overflow [EFloatOverflow] +echo x / y #OUT Error: unhandled exception: FPU operation caused an overflow diff --git a/tests/float/tfloat2.nim b/tests/float/tfloat2.nim index 51883674f..b84120fba 100644 --- a/tests/float/tfloat2.nim +++ b/tests/float/tfloat2.nim @@ -1,6 +1,6 @@ discard """ file: "tfloat2.nim" - outputsub: "Error: unhandled exception: FPU operation caused a NaN result [EFloatInvalidOp]" + outputsub: "Error: unhandled exception: FPU operation caused a NaN result [FloatInvalidOpError]" exitcode: "1" """ # Test new floating point exceptions @@ -10,6 +10,6 @@ discard """ var x = 0.0 var y = 0.0 -echo x / y #OUT Error: unhandled exception: FPU operation caused a NaN result [EFloatInvalidOp] +echo x / y #OUT Error: unhandled exception: FPU operation caused a NaN result diff --git a/tests/float/tfloat3.nim b/tests/float/tfloat3.nim index 4382dd3ed..a3f5a2fc7 100644 --- a/tests/float/tfloat3.nim +++ b/tests/float/tfloat3.nim @@ -1,6 +1,6 @@ discard """ file: "tfloat3.nim" - output: "Nimrod 3.4368930843, 0.3299290698 C double: 3.4368930843, 0.3299290698" + output: "Nim 3.4368930843, 0.3299290698 C double: 3.4368930843, 0.3299290698" """ import math, strutils @@ -13,11 +13,11 @@ void printFloats(void) { } """.} -proc c_printf(frmt: CString) {.importc: "printf", header: "<stdio.h>", varargs.} +proc c_printf(frmt: cstring) {.importc: "printf", header: "<stdio.h>", varargs.} proc printFloats {.importc, nodecl.} var x: float = 1.234567890123456789 -c_printf("Nimrod %.10f, %.10f ", exp(x), cos(x)) +c_printf("Nim %.10f, %.10f ", exp(x), cos(x)) printFloats() diff --git a/tests/gc/bintrees.nim b/tests/gc/bintrees.nim index 3f8acee1e..5b65bb437 100644 --- a/tests/gc/bintrees.nim +++ b/tests/gc/bintrees.nim @@ -1,4 +1,4 @@ -# -*- nimrod -*- +# -*- nim -*- import os, strutils diff --git a/tests/gc/closureleak.nim b/tests/gc/closureleak.nim index 669e05227..38ee1250a 100644 --- a/tests/gc/closureleak.nim +++ b/tests/gc/closureleak.nim @@ -29,5 +29,5 @@ for i in 0 .. <10: f.func = proc = echo f.id -gc_fullcollect() +GC_fullcollect() echo alive_foos.len <= 3 diff --git a/tests/generics/tcan_alias_generic.nim b/tests/generics/tcan_alias_generic.nim index e90bdc6d2..780a47841 100644 --- a/tests/generics/tcan_alias_generic.nim +++ b/tests/generics/tcan_alias_generic.nim @@ -1,5 +1,5 @@ ## -## can_alias_generic Nimrod Module +## can_alias_generic Nim Module ## ## Created by Eric Doughty-Papassideris on 2011-02-16. ## Copyright (c) 2011 FWA. All rights reserved. diff --git a/tests/generics/tcan_alias_specialised_generic.nim b/tests/generics/tcan_alias_specialised_generic.nim index 8d4a29abd..a737d3580 100644 --- a/tests/generics/tcan_alias_specialised_generic.nim +++ b/tests/generics/tcan_alias_specialised_generic.nim @@ -3,7 +3,7 @@ discard """ """ ## -## can_alias_specialised_generic Nimrod Module +## can_alias_specialised_generic Nim Module ## ## Created by Eric Doughty-Papassideris on 2011-02-16. ## Copyright (c) 2011 FWA. All rights reserved. diff --git a/tests/generics/tcan_inherit_generic.nim b/tests/generics/tcan_inherit_generic.nim index a6f4d946b..ce2b6452f 100644 --- a/tests/generics/tcan_inherit_generic.nim +++ b/tests/generics/tcan_inherit_generic.nim @@ -1,5 +1,5 @@ ## -## can_inherit_generic Nimrod Module +## can_inherit_generic Nim Module ## ## Created by Eric Doughty-Papassideris on 2011-02-16. ## Copyright (c) 2011 FWA. All rights reserved. diff --git a/tests/generics/tcan_specialise_generic.nim b/tests/generics/tcan_specialise_generic.nim index 64d5f56e3..c510910e8 100644 --- a/tests/generics/tcan_specialise_generic.nim +++ b/tests/generics/tcan_specialise_generic.nim @@ -1,5 +1,5 @@ ## -## can_specialise_generic Nimrod Module +## can_specialise_generic Nim Module ## ## Created by Eric Doughty-Papassideris on 2011-02-16. ## Copyright (c) 2011 FWA. All rights reserved. diff --git a/tests/generics/texplicitgeneric1.nim b/tests/generics/texplicitgeneric1.nim index 6cca71ac0..d54044368 100644 --- a/tests/generics/texplicitgeneric1.nim +++ b/tests/generics/texplicitgeneric1.nim @@ -18,7 +18,7 @@ proc newDict*[TKey, TValue](): PDict[TKey, TValue] = proc add*[TKey, TValue](d: PDict[TKey, TValue], k: TKey, v: TValue) = d.data.add((k, v)) -iterator items*[Tkey, tValue](d: PDict[TKey, TValue]): tuple[k: TKey, +iterator items*[Tkey, TValue](d: PDict[TKey, TValue]): tuple[k: TKey, v: TValue] = for k, v in items(d.data): yield (k, v) diff --git a/tests/generics/tgeneric0.nim b/tests/generics/tgeneric0.nim index 9292b729f..45450ccca 100644 --- a/tests/generics/tgeneric0.nim +++ b/tests/generics/tgeneric0.nim @@ -1,9 +1,9 @@ import tables type - TX = TTable[string, int] + TX = Table[string, int] -proc foo(models: seq[TTable[string, float]]): seq[float] = +proc foo(models: seq[Table[string, float]]): seq[float] = result = @[] for model in models.items: result.add model["foobar"] @@ -16,4 +16,12 @@ proc foo[T](p: TType[T, range[0..1]]) = proc foo[T](p: TType[T, range[0..2]]) = echo "bar" +#bug #1366 + +proc reversed(x) = + for i in countdown(x.low, x.high): + echo i + +reversed(@[-19, 7, -4, 6]) + diff --git a/tests/generics/tgeneric2.nim b/tests/generics/tgeneric2.nim index 56803017a..21eb4693e 100644 --- a/tests/generics/tgeneric2.nim +++ b/tests/generics/tgeneric2.nim @@ -1,7 +1,7 @@ import tables type - TX = TTable[string, int] + TX = Table[string, int] proc foo(models: seq[TX]): seq[int] = result = @[] @@ -9,7 +9,7 @@ proc foo(models: seq[TX]): seq[int] = result.add model["foobar"] type - obj = object - field: TTable[string, string] + Obj = object + field: Table[string, string] var t: Obj discard initTable[type(t.field), string]() diff --git a/tests/generics/tgeneric3.nim b/tests/generics/tgeneric3.nim index 963d0ccfb..6fb929efb 100644 --- a/tests/generics/tgeneric3.nim +++ b/tests/generics/tgeneric3.nim @@ -7,17 +7,17 @@ type value: D node: PNode[T,D] when not (D is string): - val_set: Bool + val_set: bool TItems[T,D] = seq[ref TItem[T,D]] TNode {.acyclic, pure, final, shallow.} [T,D] = object slots: TItems[T,D] left: PNode[T,D] - count: Int32 + count: int32 RPath[T,D] = tuple[ - Xi: Int, + Xi: int, Nd: PNode[T,D] ] const @@ -29,41 +29,41 @@ const cLenMax = 128 cCenter = cLenMax div 2 -proc len[T,D] (n:PNode[T,D]): Int {.inline.} = - return n.Count +proc len[T,D] (n:PNode[T,D]): int {.inline.} = + return n.count -proc clean[T: TOrdinal|TNumber](o: var T) {.inline.} = discard +proc clean[T: SomeOrdinal|SomeNumber](o: var T) {.inline.} = discard proc clean[T: string|seq](o: var T) {.inline.} = o = nil proc clean[T,D] (o: ref TItem[T,D]) {.inline.} = when (D is string) : - o.Value = nil + o.value = nil else : o.val_set = false -proc isClean[T,D] (it: ref TItem[T,D]): Bool {.inline.} = +proc isClean[T,D] (it: ref TItem[T,D]): bool {.inline.} = when (D is string) : - return it.Value == nil + return it.value == nil else : return not it.val_set -proc isClean[T,D] (n: PNode[T,D], x: Int): Bool {.inline.} = - when (D is string) : - return n.slots[x].Value == nil - else : +proc isClean[T,D](n: PNode[T,D], x: int): bool {.inline.} = + when (D is string): + return n.slots[x].value == nil + else: return not n.slots[x].val_set -proc setItem[T,D] (AKey: T, AValue: D, ANode: PNode[T,D]): ref TItem[T,D] {.inline.} = - new(Result) - Result.Key = AKey - Result.Value = AValue - Result.Node = ANode +proc setItem[T,D](Akey: T, Avalue: D, ANode: PNode[T,D]): ref TItem[T,D] {.inline.} = + new(result) + result.key = Akey + result.value = Avalue + result.node = ANode when not (D is string) : - Result.val_set = true + result.val_set = true -proc cmp[T:Int8|Int16|Int32|Int64|Int] (a,b: T): T {.inline.} = +proc cmp[T:int8|int16|int32|int64|int] (a,b: T): T {.inline.} = return a-b template binSearchImpl *(docmp: expr) {.immediate.} = @@ -76,41 +76,41 @@ template binSearchImpl *(docmp: expr) {.immediate.} = if SW < 0: result = I + 1 else: H = I - 1 - if SW == 0 : bFound = True + if SW == 0 : bFound = true if bFound: inc(result) else: result = - result -proc bSearch[T,D] (haystack: PNode[T,D], needle:T): Int {.inline.} = +proc bSearch[T,D] (haystack: PNode[T,D], needle:T): int {.inline.} = binSearchImpl(haystack.slots[I].key.cmp(needle)) -proc DeleteItem[T,D] (n: PNode[T,D], x: Int): PNode[T,D] {.inline.} = +proc DeleteItem[T,D] (n: PNode[T,D], x: int): PNode[T,D] {.inline.} = var w = n.slots[x] - if w.Node != nil : + if w.node != nil : clean(w) return n - dec(n.Count) - if n.Count > 0 : - for i in countup(x, n.Count -1) : n.slots[i] = n.slots[i + 1] - n.slots[n.Count] = nil - case n.Count + dec(n.count) + if n.count > 0 : + for i in countup(x, n.count -1) : n.slots[i] = n.slots[i + 1] + n.slots[n.count] = nil + case n.count of cLen1 : setLen(n.slots, cLen1) of cLen2 : setLen(n.slots, cLen2) of cLen3 : setLen(n.slots, cLen3) of cLenCenter : setLen(n.slots, cLenCenter) of cLen4 : setLen(n.slots, cLen4) else: discard - Result = n + result = n else : - Result = n.Left + result = n.left n.slots = nil - n.Left = nil + n.left = nil -proc InternalDelete[T,D] (ANode: PNode[T,D], key: T, AValue: var D): PNode[T,D] = +proc internalDelete[T,D] (ANode: PNode[T,D], key: T, Avalue: var D): PNode[T,D] = var Path: array[0..20, RPath[T,D]] var n = ANode - Result = n - clean(AValue) + result = n + clean(Avalue) var h = 0 while n != nil: var x = bSearch(n, key) @@ -119,17 +119,17 @@ proc InternalDelete[T,D] (ANode: PNode[T,D], key: T, AValue: var D): PNode[T,D] Path[h].Xi = - x inc(h) if x == 0 : - n = n.Left + n = n.left else : x = (-x) -1 - if x < n.Count : - n = n.slots[x].Node + if x < n.count : + n = n.slots[x].node else : n = nil else : dec(x) if isClean(n, x) : return - AValue = n.slots[x].Value + Avalue = n.slots[x].value var n2 = DeleteItem(n, x) dec(h) while (n2 != n) and (h >=0) : @@ -139,30 +139,30 @@ proc InternalDelete[T,D] (ANode: PNode[T,D], key: T, AValue: var D): PNode[T,D] if x >= 0 : if (n == nil) and isClean(w.Nd, x) : n = w.Nd - n.slots[x].Node = nil + n.slots[x].node = nil n2 = DeleteItem(n, x) else : - w.Nd.slots[x].Node = n + w.Nd.slots[x].node = n return else : - w.Nd.Left = n + w.Nd.left = n return dec(h) if h < 0: - Result = n2 + result = n2 return -proc InternalFind[T,D] (n: PNode[T,D], key: T): ref TItem[T,D] {.inline.} = +proc internalFind[T,D] (n: PNode[T,D], key: T): ref TItem[T,D] {.inline.} = var wn = n while wn != nil : var x = bSearch(wn, key) if x <= 0 : if x == 0 : - wn = wn.Left + wn = wn.left else : x = (-x) -1 - if x < wn.Count : - wn = wn.slots[x].Node + if x < wn.count : + wn = wn.slots[x].node else : return nil @@ -171,32 +171,32 @@ proc InternalFind[T,D] (n: PNode[T,D], key: T): ref TItem[T,D] {.inline.} = return nil proc traceTree[T,D](root: PNode[T,D]) = - proc traceX(x: Int) = + proc traceX(x: int) = write stdout, "(" write stdout, x write stdout, ") " proc traceEl(el: ref TItem[T,D]) = write stdout, " key: " - write stdout, el.Key + write stdout, el.key write stdout, " value: " - write stdout, el.Value + write stdout, el.value proc traceln(space: string) = writeln stdout, "" write stdout, space - proc doTrace(n: PNode[T,D], level: Int) = + proc doTrace(n: PNode[T,D], level: int) = var space = repeatChar(2 * level) traceln(space) write stdout, "node: " if n == nil: writeln stdout, "is empty" return - write stdout, n.Count + write stdout, n.count write stdout, " elements: " - if n.Left != nil: + if n.left != nil: traceln(space) write stdout, "left: " doTrace(n.left, level +1) @@ -204,188 +204,188 @@ proc traceTree[T,D](root: PNode[T,D]) = if el != nil and not isClean(el): traceln(space) traceX(i) - if i >= n.Count: + if i >= n.count: write stdout, "error " else: traceEl(el) - if el.Node != nil: doTrace(el.Node, level +1) + if el.node != nil: doTrace(el.node, level +1) else : write stdout, " empty " - elif i < n.Count : + elif i < n.count : traceln(space) traceX(i) write stdout, "clean: " when T is string : - if el.Key != nil: write stdout, el.Key - else : write stdout, el.Key - if el.Node != nil: doTrace(el.Node, level +1) + if el.key != nil: write stdout, el.key + else : write stdout, el.key + if el.node != nil: doTrace(el.node, level +1) else : write stdout, " empty " writeln stdout,"" doTrace(root, 0) -proc InsertItem[T,D](APath: RPath[T,D], ANode:PNode[T,D], AKey: T, AValue: D) = +proc InsertItem[T,D](APath: RPath[T,D], ANode:PNode[T,D], Akey: T, Avalue: D) = var x = - APath.Xi - inc(APath.Nd.Count) - case APath.Nd.Count + inc(APath.Nd.count) + case APath.Nd.count of cLen1: setLen(APath.Nd.slots, cLen2) of cLen2: setLen(APath.Nd.slots, cLen3) of cLen3: setLen(APath.Nd.slots, cLenCenter) of cLenCenter: setLen(APath.Nd.slots, cLen4) of cLen4: setLen(APath.Nd.slots, cLenMax) else: discard - for i in countdown(APath.Nd.Count.int - 1, x + 1): shallowCopy(APath.Nd.slots[i], APath.Nd.slots[i - 1]) - APath.Nd.slots[x] = setItem(AKey, AValue, ANode) + for i in countdown(APath.Nd.count.int - 1, x + 1): shallowCopy(APath.Nd.slots[i], APath.Nd.slots[i - 1]) + APath.Nd.slots[x] = setItem(Akey, Avalue, ANode) -proc SplitPage[T,D](n, left: PNode[T,D], xi: Int, AKey:var T, AValue:var D): PNode[T,D] = - var x = -Xi +proc SplitPage[T,D](n, left: PNode[T,D], xi: int, Akey:var T, Avalue:var D): PNode[T,D] = + var x = -xi var it1: TItems[T,D] it1.newSeq(cLenCenter) - new(Result) - Result.slots.newSeq(cLenCenter) - Result.Count = cCenter + new(result) + result.slots.newSeq(cLenCenter) + result.count = cCenter if x == cCenter: for i in 0..cCenter -1: shallowCopy(it1[i], left.slots[i]) - for i in 0..cCenter -1: shallowCopy(Result.slots[i], left.slots[cCenter + i]) - Result.Left = n + for i in 0..cCenter -1: shallowCopy(result.slots[i], left.slots[cCenter + i]) + result.left = n else : if x < cCenter : for i in 0..x-1: shallowCopy(it1[i], left.slots[i]) - it1[x] = setItem(AKey, AValue, n) + it1[x] = setItem(Akey, Avalue, n) for i in x+1 .. cCenter -1: shallowCopy(it1[i], left.slots[i-1]) var w = left.slots[cCenter -1] - AKey = w.Key - AValue = w.Value - Result.Left = w.Node - for i in 0..cCenter -1: shallowCopy(Result.slots[i], left.slots[cCenter + i]) + Akey = w.key + Avalue = w.value + result.left = w.node + for i in 0..cCenter -1: shallowCopy(result.slots[i], left.slots[cCenter + i]) else : for i in 0..cCenter -1: shallowCopy(it1[i], left.slots[i]) x = x - (cCenter + 1) - for i in 0..x-1: shallowCopy(Result.slots[i], left.slots[cCenter + i + 1]) - Result.slots[x] = setItem(AKey, AValue, n) - for i in x+1 .. cCenter -1: shallowCopy(Result.slots[i], left.slots[cCenter + i]) + for i in 0..x-1: shallowCopy(result.slots[i], left.slots[cCenter + i + 1]) + result.slots[x] = setItem(Akey, Avalue, n) + for i in x+1 .. cCenter -1: shallowCopy(result.slots[i], left.slots[cCenter + i]) var w = left.slots[cCenter] - AKey = w.Key - AValue = w.Value - Result.Left = w.Node - left.Count = cCenter + Akey = w.key + Avalue = w.value + result.left = w.node + left.count = cCenter shallowCopy(left.slots, it1) -proc InternalPut[T,D](ANode: ref TNode[T,D], AKey: T, AValue: D, OldValue: var D): ref TNode[T,D] = - var h: Int +proc internalPut[T,D](ANode: ref TNode[T,D], Akey: T, Avalue: D, Oldvalue: var D): ref TNode[T,D] = + var h: int var Path: array[0..30, RPath[T,D]] var left: PNode[T,D] var n = ANode - Result = ANode + result = ANode h = 0 while n != nil: - var x = bSearch[T,D](n, AKey) + var x = bSearch[T,D](n, Akey) if x <= 0 : Path[h].Nd = n Path[h].Xi = x inc(h) if x == 0 : - n = n.Left + n = n.left else : x = (-x) -1 - if x < n.Count : - n = n.slots[x].Node + if x < n.count : + n = n.slots[x].node else : n = nil else : var w = n.slots[x - 1] - OldValue = w.Value - w.Value = AValue + Oldvalue = w.value + w.value = Avalue return dec(h) left = nil - var lKey = AKey - var lValue = AValue + var lkey = Akey + var lvalue = Avalue while h >= 0 : - if Path[h].Nd.Count < cLenMax : - InsertItem(Path[h], n, lKey, lValue) + if Path[h].Nd.count < cLenMax : + InsertItem(Path[h], n, lkey, lvalue) return else : left = Path[h].Nd - n = SplitPage(n, left, Path[h].Xi, lKey, lValue) + n = SplitPage(n, left, Path[h].Xi, lkey, lvalue) dec(h) - new(Result) - Result.slots.newSeq(cLen1) - Result.Count = 1 - Result.Left = left - Result.slots[0] = setItem(lKey, lValue, n) + new(result) + result.slots.newSeq(cLen1) + result.count = 1 + result.left = left + result.slots[0] = setItem(lkey, lvalue, n) proc CleanTree[T,D](n: PNode[T,D]): PNode[T,D] = - if n.Left != nil : - n.Left = CleanTree(n.Left) - for i in 0 .. n.Count - 1 : + if n.left != nil : + n.left = CleanTree(n.left) + for i in 0 .. n.count - 1 : var w = n.slots[i] - if w.Node != nil : - w.Node = CleanTree(w.Node) - clean(w.Value) - clean(w.Key) + if w.node != nil : + w.node = CleanTree(w.node) + clean(w.value) + clean(w.key) n.slots = nil return nil proc VisitAllNodes[T,D](n: PNode[T,D], visit: proc(n: PNode[T,D]): PNode[T,D] {.closure.} ): PNode[T,D] = if n != nil : - if n.Left != nil : - n.Left = VisitAllNodes(n.Left, visit) - for i in 0 .. n.Count - 1 : + if n.left != nil : + n.left = VisitAllNodes(n.left, visit) + for i in 0 .. n.count - 1 : var w = n.slots[i] - if w.Node != nil : - w.Node = VisitAllNodes(w.Node, visit) + if w.node != nil : + w.node = VisitAllNodes(w.node, visit) return visit(n) return nil proc VisitAllNodes[T,D](n: PNode[T,D], visit: proc(n: PNode[T,D]) {.closure.} ) = if n != nil: - if n.Left != nil : - VisitAllNodes(n.Left, visit) - for i in 0 .. n.Count - 1 : + if n.left != nil : + VisitAllNodes(n.left, visit) + for i in 0 .. n.count - 1 : var w = n.slots[i] - if w.Node != nil : - VisitAllNodes(w.Node, visit) + if w.node != nil : + VisitAllNodes(w.node, visit) visit(n) -proc VisitAll[T,D](n: PNode[T,D], visit: proc(AKey: T, AValue: D) {.closure.} ) = +proc VisitAll[T,D](n: PNode[T,D], visit: proc(Akey: T, Avalue: D) {.closure.} ) = if n != nil: - if n.Left != nil : - VisitAll(n.Left, visit) - for i in 0 .. n.Count - 1 : + if n.left != nil : + VisitAll(n.left, visit) + for i in 0 .. n.count - 1 : var w = n.slots[i] if not w.isClean : - visit(w.Key, w.Value) - if w.Node != nil : - VisitAll(w.Node, visit) + visit(w.key, w.value) + if w.node != nil : + VisitAll(w.node, visit) -proc VisitAll[T,D](n: PNode[T,D], visit: proc(AKey: T, AValue: var D):Bool {.closure.} ): PNode[T,D] = +proc VisitAll[T,D](n: PNode[T,D], visit: proc(Akey: T, Avalue: var D):bool {.closure.} ): PNode[T,D] = if n != nil: - var n1 = n.Left + var n1 = n.left if n1 != nil : var n2 = VisitAll(n1, visit) if n1 != n2 : - n.Left = n2 + n.left = n2 var i = 0 - while i < n.Count : + while i < n.count : var w = n.slots[i] if not w.isClean : - if visit(w.Key, w.Value) : - Result = DeleteItem(n, i) - if Result == nil : return + if visit(w.key, w.value) : + result = DeleteItem(n, i) + if result == nil : return dec(i) - n1 = w.Node + n1 = w.node if n1 != nil : var n2 = VisitAll(n1, visit) if n1 != n2 : - w.Node = n2 + w.node = n2 inc(i) return n @@ -396,20 +396,20 @@ iterator keys* [T,D] (n: PNode[T,D]): T = var nd = n var i = -1 while true : - if i < nd.Count : + if i < nd.count : Path[level].Nd = nd Path[level].Xi = i if i < 0 : - if nd.Left != nil : - nd = nd.Left + if nd.left != nil : + nd = nd.left inc(level) else : inc(i) else : var w = nd.slots[i] if not w.isClean() : - yield w.Key - if w.Node != nil : - nd = w.Node + yield w.key + if w.node != nil : + nd = w.node i = -1 inc(level) else : inc(i) @@ -424,22 +424,22 @@ iterator keys* [T,D] (n: PNode[T,D]): T = when isMainModule: proc test() = - var oldValue: Int - var root = InternalPut[int, int](nil, 312, 312, oldValue) - var someOtherRoot = InternalPut[string, int](nil, "312", 312, oldValue) - var it1 = InternalFind(root, 312) - echo it1.Value + var oldvalue: int + var root = internalPut[int, int](nil, 312, 312, oldvalue) + var someOtherRoot = internalPut[string, int](nil, "312", 312, oldvalue) + var it1 = internalFind(root, 312) + echo it1.value for i in 1..1_000_000: - root = InternalPut(root, i, i, oldValue) + root = internalPut(root, i, i, oldvalue) var cnt = 0 - oldValue = -1 + oldvalue = -1 when true : # code compiles, when this or the other when is switched to false for k in root.keys : - if k <= oldValue : + if k <= oldvalue : echo k - oldValue = k + oldvalue = k inc(cnt) echo cnt when true : @@ -450,21 +450,21 @@ when isMainModule: root = VisitAll(root, proc(key: int, value: var int): bool = return key mod 2 == 0 ) cnt = 0 - oldValue = -1 + oldvalue = -1 VisitAll(root, proc(key: int, value: int) {.closure.} = - if key <= oldValue : + if key <= oldvalue : echo key - oldValue = key + oldvalue = key inc(cnt) ) echo cnt root = VisitAll(root, proc(key: int, value: var int): bool = return key mod 2 != 0 ) cnt = 0 - oldValue = -1 + oldvalue = -1 VisitAll(root, proc(key: int, value: int) {.closure.} = - if key <= oldValue : + if key <= oldvalue : echo "error ", key - oldValue = key + oldvalue = key inc(cnt) ) echo cnt #traceTree(root) diff --git a/tests/generics/tgenericprocvar.nim b/tests/generics/tgenericprocvar.nim index 1eba81fec..dca9c8538 100644 --- a/tests/generics/tgenericprocvar.nim +++ b/tests/generics/tgenericprocvar.nim @@ -25,7 +25,7 @@ proc filter[T,D](data: seq[T], env:D, pred: TFilterProc[T,D]): seq[T] = for e in data: if pred(e, env): result.add(e) -proc predTest(item: int, value: int): Bool = +proc predTest(item: int, value: int): bool = return item <= value proc test(data: seq[int], value: int): seq[int] = diff --git a/tests/generics/tgenericvariant.nim b/tests/generics/tgenericvariant.nim index 51d01355a..0150cda8d 100644 --- a/tests/generics/tgenericvariant.nim +++ b/tests/generics/tgenericvariant.nim @@ -1,15 +1,15 @@ type TMaybe[T] = object - case empty: Bool - of False: value: T + case empty: bool + of false: value: T else: nil proc Just*[T](val: T): TMaybe[T] = - result.empty = False + result.empty = false result.value = val proc Nothing[T](): TMaybe[T] = - result.empty = True + result.empty = true proc safeReadLine(): TMaybe[string] = var r = stdin.readLine() diff --git a/tests/generics/tinferredgenericprocs.nim b/tests/generics/tinferredgenericprocs.nim index ac445fd32..12adfe965 100644 --- a/tests/generics/tinferredgenericprocs.nim +++ b/tests/generics/tinferredgenericprocs.nim @@ -5,7 +5,7 @@ discard """ 3''' """ -# https://github.com/Araq/Nimrod/issues/797 +# https://github.com/Araq/Nim/issues/797 proc foo[T](s:T):string = $s type IntStringProc = proc(x: int): string diff --git a/tests/generics/tmetafield.nim b/tests/generics/tmetafield.nim index e1bc43ce3..bbfca7e3c 100644 --- a/tests/generics/tmetafield.nim +++ b/tests/generics/tmetafield.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nimrod check $options $file" + cmd: "nim check $options $file" errormsg: "'proc' is not a concrete type" errormsg: "'Foo' is not a concrete type." errormsg: "invalid type: 'TBaseMed'" diff --git a/tests/generics/tspecialised_is_equivalent.nim b/tests/generics/tspecialised_is_equivalent.nim index 60b976e90..ace562862 100644 --- a/tests/generics/tspecialised_is_equivalent.nim +++ b/tests/generics/tspecialised_is_equivalent.nim @@ -1,5 +1,5 @@ ## -## specialised_is_equivalent Nimrod Module +## specialised_is_equivalent Nim Module ## ## Created by Eric Doughty-Papassideris on 2011-02-16. ## Copyright (c) 2011 FWA. All rights reserved. diff --git a/tests/generics/tthread_generic.nim b/tests/generics/tthread_generic.nim index 7109bba18..5887f7db3 100644 --- a/tests/generics/tthread_generic.nim +++ b/tests/generics/tthread_generic.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nimrod $target --hints:on --threads:on $options $file" + cmd: "nim $target --hints:on --threads:on $options $file" """ type diff --git a/tests/iter/titer2.nim b/tests/iter/titer2.nim index 71c7327a7..5c407ebe4 100644 --- a/tests/iter/titer2.nim +++ b/tests/iter/titer2.nim @@ -1,6 +1,6 @@ discard """ output: '''true''' - cmd: "nimrod $target --gc:none --hints:on --warnings:off $options $file" + cmd: "nim $target --gc:none --hints:on --warnings:off $options $file" """ import hashes @@ -44,8 +44,8 @@ block Test1: # a non-generic iterator! var t = initTable[int, string]() - for k, v in t.pairs: nil - for k, v in t.pairs: nil + for k, v in t.pairs: discard + for k, v in t.pairs: discard echo "true" diff --git a/tests/iter/titer6.nim b/tests/iter/titer6.nim index dceace0e0..2abfa0860 100644 --- a/tests/iter/titer6.nim +++ b/tests/iter/titer6.nim @@ -21,13 +21,13 @@ iterator tokenize2(s: string, seps: set[char] = Whitespace): tuple[ yield (substr(s, i, j-1), false) i = j -for word, isSep in tokenize2("ta da", whiteSpace): +for word, isSep in tokenize2("ta da", WhiteSpace): var titer2TestVar = 0 stdout.write(titer2TestVar) proc wordWrap2(s: string, maxLineWidth = 80, splitLongWords = true, - seps: set[char] = whitespace, + seps: set[char] = Whitespace, newLine = "\n"): string = result = "" for word, isSep in tokenize2(s, seps): diff --git a/tests/iter/titer8.nim b/tests/iter/titer8.nim index af0e643f1..3bc01122f 100644 --- a/tests/iter/titer8.nim +++ b/tests/iter/titer8.nim @@ -47,7 +47,7 @@ iterator count3(): int {.closure.} = yield 2 yield 3 -for word, isSep in tokenize2("ta da", whiteSpace): +for word, isSep in tokenize2("ta da", WhiteSpace): if not isSep: stdout.write(word) echo "" @@ -56,7 +56,7 @@ proc inProc() = for c in count3(): echo c - for word, isSep in tokenize2("ta da", whiteSpace): + for word, isSep in tokenize2("ta da", WhiteSpace): stdout.write(word) for c in count3(): diff --git a/tests/js.nim b/tests/js.nim index becc17834..e5e432366 100644 --- a/tests/js.nim +++ b/tests/js.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nimrod js --hints:on $options $file" + cmd: "nim js --hints:on $options $file" """ # This file tests the JavaScript generator diff --git a/tests/let/tlet.nim b/tests/let/tlet.nim index 3d36432fb..6703ba254 100644 --- a/tests/let/tlet.nim +++ b/tests/let/tlet.nim @@ -3,9 +3,9 @@ discard """ errormsg: "'name' cannot be assigned to" """ -Echo("What's your name? ") +echo("What's your name? ") let name = readLine(stdin) while name == "": - Echo("Please tell me your name: ") + echo("Please tell me your name: ") name = readLine(stdin) diff --git a/tests/lookups/tkoeniglookup.nim b/tests/lookups/tkoeniglookup.nim index e6f5c0112..6c42798ae 100644 --- a/tests/lookups/tkoeniglookup.nim +++ b/tests/lookups/tkoeniglookup.nim @@ -2,7 +2,7 @@ discard """ output: '''x: 0 y: 0''' """ -proc ToString*[T](x: T): string = return $x +proc toString*[T](x: T): string = return $x type diff --git a/tests/macros/tdebugstmt.nim b/tests/macros/tdebugstmt.nim index 865dc436a..00c55ccd8 100644 --- a/tests/macros/tdebugstmt.nim +++ b/tests/macros/tdebugstmt.nim @@ -7,7 +7,7 @@ x: some string''' import macros macro debug(n: varargs[expr]): stmt = - # `n` is a Nimrod AST that contains the whole macro invocation + # `n` is a Nim AST that contains the whole macro invocation # this macro returns a list of statements: result = newNimNode(nnkStmtList, n) # iterate over any argument that is passed to this macro: diff --git a/tests/manyloc/argument_parser/argument_parser.nim b/tests/manyloc/argument_parser/argument_parser.nim index 6f4fb650e..fec00dbf8 100644 --- a/tests/manyloc/argument_parser/argument_parser.nim +++ b/tests/manyloc/argument_parser/argument_parser.nim @@ -1,7 +1,7 @@ ## Command line parsing module for Nimrod. ## -## `Nimrod <http://nimrod-code.org>`_ provides the `parseopt module -## <http://nimrod-code.org/parseopt.html>`_ to parse options from the +## `Nim <http://nim-code.org>`_ provides the `parseopt module +## <http://nim-code.org/parseopt.html>`_ to parse options from the ## commandline. This module tries to provide functionality to prevent you from ## writing commandline parsing and let you concentrate on providing the best ## possible experience for your users. @@ -76,14 +76,14 @@ type case kind*: Tparam_kind of PK_EMPTY: nil of PK_INT: int_val*: int - of PK_BIGGEST_INT: big_int_val*: biggestInt + of PK_BIGGEST_INT: big_int_val*: BiggestInt of PK_FLOAT: float_val*: float - of PK_BIGGEST_FLOAT: big_float_val*: biggestFloat + of PK_BIGGEST_FLOAT: big_float_val*: BiggestFloat of PK_STRING: str_val*: string of PK_BOOL: bool_val*: bool of PK_HELP: nil - Tcommandline_results* = object of TObject ## \ + Tcommandline_results* = object of RootObj ## \ ## Contains the results of the parsing. ## ## Usually this is the result of the parse() call, but you can inherit from @@ -97,7 +97,7 @@ type ## the first name variant for all options to avoid you repeating the test ## with different keys. positional_parameters*: seq[Tparsed_parameter] - options*: TOrderedTable[string, Tparsed_parameter] + options*: OrderedTable[string, Tparsed_parameter] # - Tparam_kind procs @@ -169,7 +169,7 @@ template new_parsed_parameter*(tkind: Tparam_kind, expr): Tparsed_parameter = ## assign the variable to, and thus you reduce code clutter and may use this ## to initialise single assignments variables in `let` blocks. Example: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## let ## parsed_param1 = new_parsed_parameter(PK_FLOAT, 3.41) ## parsed_param2 = new_parsed_parameter(PK_BIGGEST_INT, 2358123 * 23123) @@ -193,7 +193,7 @@ template new_parsed_parameter*(tkind: Tparam_kind, expr): Tparsed_parameter = proc init*(param: var Tcommandline_results; positional_parameters: seq[Tparsed_parameter] = @[]; - options: TOrderedTable[string, Tparsed_parameter] = + options: OrderedTable[string, Tparsed_parameter] = initOrderedTable[string, Tparsed_parameter](4)) = ## Initialization helper with default parameters. param.positional_parameters = positional_parameters @@ -231,12 +231,12 @@ template run_custom_proc(parsed_parameter: Tparsed_parameter, ## Pass in the string of the parameter triggering the call. If the if not custom_validator.isNil: except: - raise_or_quit(EInvalidValue, ("Couldn't run custom proc for " & + raise_or_quit(ValueError, ("Couldn't run custom proc for " & "parameter $1:\n$2" % [escape(parameter), getCurrentExceptionMsg()])) let message = custom_validator(parameter, parsed_parameter) if not message.isNil and message.len > 0: - raise_or_quit(EInvalidValue, ("Failed to validate value for " & + raise_or_quit(ValueError, ("Failed to validate value for " & "parameter $1:\n$2" % [escape(parameter), message])) @@ -246,50 +246,50 @@ proc parse_parameter(quit_on_failure: bool, param, value: string, ## ## Pass the parameter string which requires a value and the text the user ## passed in for it. It will be parsed according to the param_kind. This proc - ## will raise (EInvalidValue, EOverflow) if something can't be parsed. + ## will raise (ValueError, EOverflow) if something can't be parsed. result.kind = param_kind case param_kind: of PK_INT: try: result.int_val = value.parseInt - except EOverflow: - raise_or_quit(EOverflow, ("parameter $1 requires an " & + except OverflowError: + raise_or_quit(OverflowError, ("parameter $1 requires an " & "integer, but $2 is too large to fit into one") % [param, escape(value)]) - except EInvalidValue: - raise_or_quit(EInvalidValue, ("parameter $1 requires an " & + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires an " & "integer, but $2 can't be parsed into one") % [param, escape(value)]) of PK_STRING: result.str_val = value of PK_FLOAT: try: result.float_val = value.parseFloat - except EInvalidValue: - raise_or_quit(EInvalidValue, ("parameter $1 requires a " & + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires a " & "float, but $2 can't be parsed into one") % [param, escape(value)]) of PK_BOOL: try: result.bool_val = value.parseBool - except EInvalidValue: - raise_or_quit(EInvalidValue, ("parameter $1 requires a " & + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires a " & "boolean, but $2 can't be parsed into one. Valid values are: " & "y, yes, true, 1, on, n, no, false, 0, off") % [param, escape(value)]) of PK_BIGGEST_INT: try: let parsed_len = parseBiggestInt(value, result.big_int_val) if value.len != parsed_len or parsed_len < 1: - raise_or_quit(EInvalidValue, ("parameter $1 requires an " & + raise_or_quit(ValueError, ("parameter $1 requires an " & "integer, but $2 can't be parsed completely into one") % [ param, escape(value)]) - except EInvalidValue: - raise_or_quit(EInvalidValue, ("parameter $1 requires an " & + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires an " & "integer, but $2 can't be parsed into one") % [param, escape(value)]) of PK_BIGGEST_FLOAT: try: let parsed_len = parseBiggestFloat(value, result.big_float_val) if value.len != parsed_len or parsed_len < 1: - raise_or_quit(EInvalidValue, ("parameter $1 requires a " & + raise_or_quit(ValueError, ("parameter $1 requires a " & "float, but $2 can't be parsed completely into one") % [ param, escape(value)]) - except EInvalidValue: - raise_or_quit(EInvalidValue, ("parameter $1 requires a " & + except ValueError: + raise_or_quit(ValueError, ("parameter $1 requires a " & "float, but $2 can't be parsed into one") % [param, escape(value)]) of PK_EMPTY: discard @@ -298,15 +298,15 @@ proc parse_parameter(quit_on_failure: bool, param, value: string, template build_specification_lookup(): - TOrderedTable[string, ptr Tparameter_specification] = + OrderedTable[string, ptr Tparameter_specification] = ## Returns the table used to keep pointers to all of the specifications. - var result {.gensym.}: TOrderedTable[string, ptr Tparameter_specification] + var result {.gensym.}: OrderedTable[string, ptr Tparameter_specification] result = initOrderedTable[string, ptr Tparameter_specification]( nextPowerOfTwo(expected.len)) for i in 0..expected.len-1: for param_to_detect in expected[i].names: if result.hasKey(param_to_detect): - raise_or_quit(EInvalidKey, + raise_or_quit(KeyError, "Parameter $1 repeated in input specification" % param_to_detect) else: result[param_to_detect] = addr(expected[i]) @@ -344,7 +344,7 @@ proc parse*(expected: seq[Tparameter_specification] = @[], ## ## If there is any kind of error and quit_on_failure is true, the quit proc ## will be called with a user error message. If quit_on_failure is false - ## errors will raise exceptions (usually EInvalidValue or EOverflow) instead + ## errors will raise exceptions (usually ValueError or EOverflow) instead ## for you to catch and handle. assert type_of_positional_parameters != PK_EMPTY and @@ -359,7 +359,7 @@ proc parse*(expected: seq[Tparameter_specification] = @[], # Prepare the input parameter list, maybe get it from the OS if not available. var args = args if args == nil: - let total_params = ParamCount() + let total_params = paramCount() #echo "Got no explicit args, retrieving from OS. Count: ", total_params newSeq(args, total_params) for i in 0..total_params - 1: @@ -387,7 +387,7 @@ proc parse*(expected: seq[Tparameter_specification] = @[], if param.consumes == PK_HELP: echo_help(expected, type_of_positional_parameters, bad_prefixes, end_of_options) - raise_or_quit(EInvalidKey, "") + raise_or_quit(KeyError, "") if param.consumes != PK_EMPTY: if i + 1 < args.len: @@ -396,14 +396,14 @@ proc parse*(expected: seq[Tparameter_specification] = @[], run_custom_proc(parsed, param.custom_validator, arg) i += 1 else: - raise_or_quit(EInvalidValue, ("parameter $1 requires a " & + raise_or_quit(ValueError, ("parameter $1 requires a " & "value, but none was provided") % [arg]) result.options[param.names[0]] = parsed break adding_positional_parameter else: for bad_prefix in bad_prefixes: if arg.startsWith(bad_prefix): - raise_or_quit(EInvalidValue, ("Found ambiguos parameter '$1' " & + raise_or_quit(ValueError, ("Found ambiguos parameter '$1' " & "starting with '$2', put '$3' as the previous parameter " & "if you want to force it as positional parameter.") % [arg, bad_prefix, end_of_options]) @@ -415,7 +415,7 @@ proc parse*(expected: seq[Tparameter_specification] = @[], i += 1 -proc toString(runes: seq[TRune]): string = +proc toString(runes: seq[Rune]): string = result = "" for rune in runes: result.add(rune.toUTF8) @@ -424,7 +424,7 @@ proc ascii_cmp(a, b: string): int = ## Comparison ignoring non ascii characters, for better switch sorting. let a = filterIt(toSeq(runes(a)), it.isAlpha()) # Can't use filterIt twice, github bug #351. - let b = filter(toSeq(runes(b)), proc(x: TRune): bool = x.isAlpha()) + let b = filter(toSeq(runes(b)), proc(x: Rune): bool = x.isAlpha()) return system.cmp(toString(a), toString(b)) diff --git a/tests/manyloc/argument_parser/ex_wget.nimrod.cfg b/tests/manyloc/argument_parser/ex_wget.nim.cfg index 4ea571d31..4ea571d31 100644 --- a/tests/manyloc/argument_parser/ex_wget.nimrod.cfg +++ b/tests/manyloc/argument_parser/ex_wget.nim.cfg diff --git a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim index d9c933939..d079a2e72 100644 --- a/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim +++ b/tests/manyloc/keineschweine/dependencies/chipmunk/chipmunk.nim @@ -21,8 +21,8 @@ const Lib = "libchipmunk.so.6.1.1" -when defined(MoreNimrod): - {.hint: "MoreNimrod defined; some Chipmunk functions replaced in Nimrod".} +when defined(MoreNim): + {.hint: "MoreNim defined; some Chipmunk functions replaced in Nim".} {.deadCodeElim: on.} from math import sqrt, sin, cos, arctan2 when defined(CpUseFloat): @@ -729,7 +729,7 @@ proc isRogue*(body: PBody): Bool {.inline.} = defGetter(PBody, CpFloat, m, Mass) #/ Set the mass of a body. -when defined(MoreNimrod): +when defined(MoreNim): defSetter(PBody, CpFloat, m, Mass) else: proc setMass*(body: PBody; m: CpFloat){. @@ -738,7 +738,7 @@ else: #/ Get the moment of a body. defGetter(PBody, CpFloat, i, Moment) #/ Set the moment of a body. -when defined(MoreNimrod): +when defined(MoreNim): defSetter(PBody, CpFloat, i, Moment) else: proc SetMoment*(body: PBody; i: CpFloat) {. @@ -747,7 +747,7 @@ else: #/ Get the position of a body. defGetter(PBody, TVector, p, Pos) #/ Set the position of a body. -when defined(MoreNimrod): +when defined(MoreNim): defSetter(PBody, TVector, p, Pos) else: proc setPos*(body: PBody; pos: TVector) {. @@ -1088,7 +1088,7 @@ proc getSegmentRadius*(shape: PShape): CpFloat {. #var VersionString*{.importc: "cpVersionString", dynlib: Lib.}: cstring #/ Calculate the moment of inertia for a circle. #/ @c r1 and @c r2 are the inner and outer diameters. A solid circle has an inner diameter of 0. -when defined(MoreNimrod): +when defined(MoreNim): proc momentForCircle*(m, r1, r2: CpFloat; offset: TVector): CpFloat {.cdecl.} = result = m * (0.5 * (r1 * r1 + r2 * r2) + lenSq(offset)) else: diff --git a/tests/manyloc/keineschweine/dependencies/nake/nake.nim b/tests/manyloc/keineschweine/dependencies/nake/nake.nim index eade28c70..5828e400c 100644 --- a/tests/manyloc/keineschweine/dependencies/nake/nake.nim +++ b/tests/manyloc/keineschweine/dependencies/nake/nake.nim @@ -58,7 +58,7 @@ when isMainModule: for i in 1..paramCount(): args.add paramStr(i) args.add " " - quit(shell("nimrod", "c", "-r", "nakefile.nim", args)) + quit(shell("nim", "c", "-r", "nakefile.nim", args)) else: addQuitProc(proc() {.noconv.} = var diff --git a/tests/manyloc/keineschweine/dependencies/nake/nakefile.nim b/tests/manyloc/keineschweine/dependencies/nake/nakefile.nim index 24af63d10..bdf2139c9 100644 --- a/tests/manyloc/keineschweine/dependencies/nake/nakefile.nim +++ b/tests/manyloc/keineschweine/dependencies/nake/nakefile.nim @@ -2,7 +2,7 @@ import nake nakeImports task "install", "compile and install nake binary": - if shell("nimrod", "c", "nake") == 0: + if shell("nim", "c", "nake") == 0: let path = getEnv("PATH").split(PathSep) for index, dir in pairs(path): echo " ", index, ". ", dir diff --git a/tests/manyloc/keineschweine/enet_server/nakefile.nim b/tests/manyloc/keineschweine/enet_server/nakefile.nim index 1ca93a340..3764c6271 100644 --- a/tests/manyloc/keineschweine/enet_server/nakefile.nim +++ b/tests/manyloc/keineschweine/enet_server/nakefile.nim @@ -5,9 +5,9 @@ const ServerDefines = "-d:NoSFML --forceBuild" task "server", "build the server": - if shell("nimrod", ServerDefines, "-r", "compile", "enet_server") != 0: + if shell("nim", ServerDefines, "-r", "compile", "enet_server") != 0: quit "Failed to build" task "gui", "build the server GUI mode": - if shell("nimrod", "--app:gui", ServerDefines, "-r", "compile", "enet_server") != 0: + if shell("nim", "--app:gui", ServerDefines, "-r", "compile", "enet_server") != 0: quit "Failed to build" diff --git a/tests/manyloc/keineschweine/keineschweine.nimrod.cfg b/tests/manyloc/keineschweine/keineschweine.nim.cfg index ca6c75f6e..ca6c75f6e 100644 --- a/tests/manyloc/keineschweine/keineschweine.nimrod.cfg +++ b/tests/manyloc/keineschweine/keineschweine.nim.cfg diff --git a/tests/manyloc/nake/nake.nim b/tests/manyloc/nake/nake.nim index 4b1b35662..04b745003 100644 --- a/tests/manyloc/nake/nake.nim +++ b/tests/manyloc/nake/nake.nim @@ -58,7 +58,7 @@ when isMainModule: for i in 1..paramCount(): args.add paramStr(i) args.add " " - quit(shell("nimrod", "c", "-r", "nakefile.nim", args)) + quit(shell("nim", "c", "-r", "nakefile.nim", args)) else: addQuitProc(proc() {.noconv.} = var diff --git a/tests/manyloc/nake/nakefile.nim b/tests/manyloc/nake/nakefile.nim index 700f9ab49..d1d712964 100644 --- a/tests/manyloc/nake/nakefile.nim +++ b/tests/manyloc/nake/nakefile.nim @@ -9,16 +9,16 @@ const BinLibs = "http://dl.dropbox.com/u/37533467/libs-2012-09-12.zip" ExeName = "keineschweine" ServerDefines = "-d:NoSFML -d:NoChipmunk" - TestBuildDefines = "-d:escapeMenuTest -d:debugWeps -d:showFPS -d:moreNimrod -d:debugKeys -d:foo -d:recordMode --forceBuild" + TestBuildDefines = "-d:escapeMenuTest -d:debugWeps -d:showFPS -d:moreNim -d:debugKeys -d:foo -d:recordMode --forceBuild" ReleaseDefines = "-d:release --deadCodeElim:on" ReleaseTestDefines = "-d:debugWeps -d:debugKeys --forceBuild" task "testprofile", "..": - if shell("nimrod", TestBuildDefines, "--profiler:on", "--stacktrace:on", "compile", ExeName) == 0: + if shell("nim", TestBuildDefines, "--profiler:on", "--stacktrace:on", "compile", ExeName) == 0: shell "."/ExeName, "offline" task "test", "Build with test defines": - if shell("nimrod", TestBuildDefines, "compile", ExeName) != 0: + if shell("nim", TestBuildDefines, "compile", ExeName) != 0: quit "The build failed." task "testrun", "Build with test defines and run": @@ -26,22 +26,22 @@ task "testrun", "Build with test defines and run": shell "."/ExeName task "test2", "Build release test build test release build": - if shell("nimrod", ReleaseDefines, ReleaseTestDefines, "compile", ExeName) == 0: + if shell("nim", ReleaseDefines, ReleaseTestDefines, "compile", ExeName) == 0: shell "."/ExeName discard """task "dirserver", "build the directory server": withDir "server": - if shell("nimrod", ServerDefines, "compile", "dirserver") != 0: + if shell("nim", ServerDefines, "compile", "dirserver") != 0: echo "Failed to build the dirserver" quit 1""" task "zoneserver", "build the zone server": withDir "enet_server": - if shell("nimrod", ServerDefines, "compile", "enet_server") != 0: + if shell("nim", ServerDefines, "compile", "enet_server") != 0: quit "Failed to build the zoneserver" task "zoneserver-gui", "build the zone server, with gui!": withDir "enet_server": - if shell("nimrod", ServerDefines, "--app:gui", "compile", "enet_server") != 0: + if shell("nim", ServerDefines, "--app:gui", "compile", "enet_server") != 0: quit "Failed to build the zoneserver" task "servers", "build the server and directory server": @@ -54,7 +54,7 @@ task "all", "run SERVERS and TEST tasks": runTask "test" task "release", "release build": - let res = shell("nimrod", ReleaseDefines, "compile", ExeName) + let res = shell("nim", ReleaseDefines, "compile", ExeName) if res != 0: echo "The build failed." quit 1 @@ -84,7 +84,7 @@ task "download", "download game assets": skipAssets = false path = expandFilename("data") path.add DirSep - path.add(extractFilename(gameAssets)) + path.add(extractFilename(GameAssets)) if existsFile(path): echo "The file already exists\n", "[R]emove [M]ove [Q]uit [S]kip Source: ", GameAssets @@ -92,7 +92,7 @@ task "download", "download game assets": of "r": removeFile path of "m": - moveFile path, path/../(extractFilename(gameAssets)&"-old") + moveFile path, path/../(extractFilename(GameAssets)&"-old") of "s": skipAssets = true else: @@ -101,7 +101,7 @@ task "download", "download game assets": echo "Downloading from ", GameAssets if not skipAssets: echo "Downloading to ", path - downloadFile gameAssets, path + downloadFile GameAssets, path echo "Download finished" let targetDir = parentDir(parentDir(path)) diff --git a/tests/manyloc/nake/nakefile.nimrod.cfg b/tests/manyloc/nake/nakefile.nim.cfg index 6f3e86fe6..6f3e86fe6 100644 --- a/tests/manyloc/nake/nakefile.nimrod.cfg +++ b/tests/manyloc/nake/nakefile.nim.cfg diff --git a/tests/manyloc/named_argument_bug/main.nimrod.cfg b/tests/manyloc/named_argument_bug/main.nim.cfg index 27cf8e688..27cf8e688 100644 --- a/tests/manyloc/named_argument_bug/main.nimrod.cfg +++ b/tests/manyloc/named_argument_bug/main.nim.cfg diff --git a/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim b/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim index a6b7bac63..3b57acb8e 100644 --- a/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim +++ b/tests/manyloc/named_argument_bug/tri_engine/math/vec.nim @@ -3,10 +3,10 @@ import tri_engine/config type - TV2*[T:TNumber=TR] = array[0..1, T] - TV3*[T:TNumber=TR] = array[0..2, T] - TV4*[T:TNumber=TR] = array[0..3, T] - TVT*[T:TNumber=TR] = TV2|TV3|TV4 + TV2*[T:SomeNumber=TR] = array[0..1, T] + TV3*[T:SomeNumber=TR] = array[0..2, T] + TV4*[T:SomeNumber=TR] = array[0..3, T] + TVT*[T:SomeNumber=TR] = TV2|TV3|TV4 #TV2* = array[0..1, TR] #TV3* = array[0..2, TR] #TV4* = array[0..3, TR] diff --git a/tests/manyloc/packages/noconflicts.nimrod.cfg b/tests/manyloc/packages/noconflicts.nim.cfg index 88974ab8c..88974ab8c 100644 --- a/tests/manyloc/packages/noconflicts.nimrod.cfg +++ b/tests/manyloc/packages/noconflicts.nim.cfg diff --git a/tests/manyloc/standalone/barebone.nimrod.cfg b/tests/manyloc/standalone/barebone.nim.cfg index 52ec64e3f..52ec64e3f 100644 --- a/tests/manyloc/standalone/barebone.nimrod.cfg +++ b/tests/manyloc/standalone/barebone.nim.cfg diff --git a/tests/metatype/tcompositetypeclasses.nim b/tests/metatype/tcompositetypeclasses.nim index a2db73769..5ae93795f 100644 --- a/tests/metatype/tcompositetypeclasses.nim +++ b/tests/metatype/tcompositetypeclasses.nim @@ -33,7 +33,7 @@ accept baz(vbaz) reject baz(vnotbaz) reject bar(vfoo) -# https://github.com/Araq/Nimrod/issues/517 +# https://github.com/Araq/Nim/issues/517 type TVecT*[T] = array[0..1, T]|array[0..2, T]|array[0..3, T] TVec2* = array[0..1, float32] @@ -43,7 +43,7 @@ proc f[T](a: TVecT[T], b: TVecT[T]): T = discard var x: float = f([0.0'f32, 0.0'f32], [0.0'f32, 0.0'f32]) var y = f(TVec2([0.0'f32, 0.0'f32]), TVec2([0.0'f32, 0.0'f32])) -# https://github.com/Araq/Nimrod/issues/602 +# https://github.com/Araq/Nim/issues/602 type TTest = object TTest2* = object diff --git a/tests/metatype/ttypeclasses.nim b/tests/metatype/ttypeclasses.nim index 677229868..db9db7713 100644 --- a/tests/metatype/ttypeclasses.nim +++ b/tests/metatype/ttypeclasses.nim @@ -1,3 +1,18 @@ +discard """ + output: '''12 +1xxx +true0 +12 +testtest +1010 +11string +testtest1 +seq +seq +seq +foo seq +foo of numeric'''""" + type TFoo[T] = object val: T diff --git a/tests/metatype/typeclassinference.nim b/tests/metatype/typeclassinference.nim index 72b5aca96..2ac037ac5 100644 --- a/tests/metatype/typeclassinference.nim +++ b/tests/metatype/typeclassinference.nim @@ -1,3 +1,8 @@ +discard """ + errormsg: "type mismatch: got (string) but expected 'ptr'" + line: 20 +""" + import typetraits type @@ -8,3 +13,9 @@ var x = Vec([1, 2, 3]) static: assert x.type.name == "Vec[static[int](3), int]" +var str1: string = "hello, world!" +var ptr1: ptr = addr(str1) + +var str2: string = "hello, world!" +var ptr2: ptr = str2 + diff --git a/tests/misc/t99bott.nim b/tests/misc/t99bott.nim index d18cb0d5c..b3b30d296 100644 --- a/tests/misc/t99bott.nim +++ b/tests/misc/t99bott.nim @@ -6,7 +6,7 @@ discard """ """ ## 99 Bottles of Beer ## http://www.99-bottles-of-beer.net/ -## Nimrod version +## Nim version ## Author: Philippe Lhoste <PhiLho(a)GMX.net> http://Phi.Lho.free.fr # 2012-11-25 diff --git a/tests/misc/tdllvar.nim b/tests/misc/tdllvar.nim index ab767770c..5a31dfbbb 100644 --- a/tests/misc/tdllvar.nim +++ b/tests/misc/tdllvar.nim @@ -2,9 +2,9 @@ import os proc getDllName: string = result = "mylib.dll" - if ExistsFile(result): return + if fileExists(result): return result = "mylib2.dll" - if ExistsFile(result): return + if fileExists(result): return quit("could not load dynamic library") proc myImport(s: cstring) {.cdecl, importc, dynlib: getDllName().} diff --git a/tests/misc/temit.nim b/tests/misc/temit.nim index ff8df0585..e2a9eaff1 100644 --- a/tests/misc/temit.nim +++ b/tests/misc/temit.nim @@ -10,8 +10,8 @@ static int cvariable = 420; """.} proc embedsC() = - var nimrodVar = 89 - {.emit: """printf("%d\n", cvariable + (int)`nimrodVar`);""".} + var nimVar = 89 + {.emit: """printf("%d\n", cvariable + (int)`nimVar`);""".} embedsC() diff --git a/tests/misc/teventemitter.nim b/tests/misc/teventemitter.nim index 9ecf72ea2..bfcf95701 100644 --- a/tests/misc/teventemitter.nim +++ b/tests/misc/teventemitter.nim @@ -5,29 +5,29 @@ discard """ import tables, lists type - TEventArgs = object of TObject - TEventEmitter = object of TObject - events*: TTable[string, TDoublyLinkedList[proc(e: TEventArgs) {.nimcall.}]] + EventArgs = object of RootObj + EventEmitter = object of RootObj + events*: Table[string, DoublyLinkedList[proc(e: EventArgs) {.nimcall.}]] -proc emit*(emitter: TEventEmitter, event: string, args: TEventArgs) = +proc emit*(emitter: EventEmitter, event: string, args: EventArgs) = for func in nodes(emitter.events[event]): func.value(args) #call function with args. -proc on*(emitter: var TEventEmitter, event: string, - func: proc(e: TEventArgs) {.nimcall.}) = +proc on*(emitter: var EventEmitter, event: string, + func: proc(e: EventArgs) {.nimcall.}) = if not hasKey(emitter.events, event): - var list: TDoublyLinkedList[proc(e: TEventArgs) {.nimcall.}] + var list: DoublyLinkedList[proc(e: EventArgs) {.nimcall.}] add(emitter.events, event, list) #if not, add it. append(emitter.events.mget(event), func) -proc initEmitter(emitter: var TEventEmitter) = +proc initEmitter(emitter: var EventEmitter) = emitter.events = initTable[string, - TDoublyLinkedList[proc(e: TEventArgs) {.nimcall.}]]() + DoublyLinkedList[proc(e: EventArgs) {.nimcall.}]]() var - ee: TEventEmitter - args: TEventArgs + ee: EventEmitter + args: EventArgs initEmitter(ee) -ee.on("print", proc(e: TEventArgs) = echo("pie")) +ee.on("print", proc(e: EventArgs) = echo("pie")) ee.emit("print", args) diff --git a/tests/misc/thallo.nim b/tests/misc/thallo.nim index 7244c27a1..cbeb45b97 100644 --- a/tests/misc/thallo.nim +++ b/tests/misc/thallo.nim @@ -37,7 +37,7 @@ macrotest(stdout) #GC_disable() -echo("This was compiled by Nimrod version " & system.nimrodVersion) +echo("This was compiled by Nim version " & system.NimVersion) writeln(stdout, "Hello", " World", "!") echo(["a", "b", "c", "d"].len) diff --git a/tests/misc/tints.nim b/tests/misc/tints.nim index fb2852af9..3e413026a 100644 --- a/tests/misc/tints.nim +++ b/tests/misc/tints.nim @@ -41,5 +41,5 @@ test(`shl`, 0xff'i8, 0x4'i8, 0xf0'i8) test(`shl`, 0xffffffff'i64, 0x4'i64, 0xffffffff0'i64) test(`shl`, 0xffffffff'i32, 0x4'i32, 0xfffffff0'i32) -Echo("Success") #OUT Success +echo("Success") #OUT Success diff --git a/tests/misc/tlastmod.nim b/tests/misc/tlastmod.nim index 75b047fc8..92ac922f7 100644 --- a/tests/misc/tlastmod.nim +++ b/tests/misc/tlastmod.nim @@ -6,13 +6,13 @@ import proc main() = var a, b: TTime - a = getLastModificationTime(ParamStr(1)) - b = getLastModificationTime(ParamStr(2)) + a = getLastModificationTime(paramStr(1)) + b = getLastModificationTime(paramStr(2)) writeln(stdout, $a) writeln(stdout, $b) if a < b: - Write(stdout, "$2 is newer than $1\n" % [ParamStr(1), ParamStr(2)]) + write(stdout, "$2 is newer than $1\n" % [paramStr(1), paramStr(2)]) else: - Write(stdout, "$1 is newer than $2\n" % [ParamStr(1), ParamStr(2)]) + write(stdout, "$1 is newer than $2\n" % [paramStr(1), paramStr(2)]) main() diff --git a/tests/misc/tloops.nim b/tests/misc/tloops.nim index f6f939769..1aada0298 100644 --- a/tests/misc/tloops.nim +++ b/tests/misc/tloops.nim @@ -31,7 +31,7 @@ proc TestLoops() = break break - while True: + while true: break diff --git a/tests/misc/tmandelbrot.nim b/tests/misc/tmandelbrot.nim index bb1b46d89..4228b0416 100644 --- a/tests/misc/tmandelbrot.nim +++ b/tests/misc/tmandelbrot.nim @@ -1,8 +1,8 @@ discard """ - cmd: "nimrod $target --hints:on -d:release $options $file" + cmd: "nim $target --hints:on -d:release $options $file" """ -# -*- nimrod -*- +# -*- nim -*- import math import os diff --git a/tests/misc/tnot.nim b/tests/misc/tnot.nim index cd0f538e6..6193e21e1 100644 --- a/tests/misc/tnot.nim +++ b/tests/misc/tnot.nim @@ -5,16 +5,16 @@ discard """ """ # BUG: following compiles, but should not: -proc nodeOfDegree(x: Int): bool = +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" + echo "Yes" else: - Echo "No" + echo "No" main() diff --git a/tests/misc/tpos.nim b/tests/misc/tpos.nim index 3d72536dd..5560ef050 100644 --- a/tests/misc/tpos.nim +++ b/tests/misc/tpos.nim @@ -14,10 +14,10 @@ proc mypos(sub, s: string, start: int = 0): int = if i >= N: result = -1 else: - while True: + while true: if s[i] == sub[j]: - Inc(i) - Inc(j) + inc(i) + inc(j) else: i = i - j + 1 j = 0 diff --git a/tests/misc/tprep.nim b/tests/misc/tprep.nim index 4ef9e2543..8f40300d6 100644 --- a/tests/misc/tprep.nim +++ b/tests/misc/tprep.nim @@ -24,7 +24,7 @@ else: var s: string -write(stdout, "compiled at " & system.compileDate & - " " & compileTime & "\n") +write(stdout, "compiled at " & system.CompileDate & + " " & CompileTime & "\n") echo getDateStr() echo getClockStr() diff --git a/tests/misc/tradix.nim b/tests/misc/tradix.nim index e5998ee12..311aa9ccd 100644 --- a/tests/misc/tradix.nim +++ b/tests/misc/tradix.nim @@ -4,7 +4,7 @@ ## We use a radix tree with node compression. ## There are two node kinds: -const bitsPerUnit = 8*sizeof(int) +const BitsPerUnit = 8*sizeof(int) type TRadixNodeKind = enum rnLinear, rnFull, rnLeafBits, rnLeafLinear @@ -42,13 +42,13 @@ proc testBit(w, i: int): bool {.inline.} = result = (w and (1 shl (i %% BitsPerUnit))) != 0 proc setBit(w: var int, i: int) {.inline.} = - w = w or (1 shl (i %% bitsPerUnit)) + w = w or (1 shl (i %% BitsPerUnit)) proc resetBit(w: var int, i: int) {.inline.} = - w = w and not (1 shl (i %% bitsPerUnit)) + w = w and not (1 shl (i %% BitsPerUnit)) proc testOrSetBit(w: var int, i: int): bool {.inline.} = - var x = (1 shl (i %% bitsPerUnit)) + var x = (1 shl (i %% BitsPerUnit)) if (w and x) != 0: return true w = w or x @@ -78,7 +78,7 @@ proc exclLeaf(r: PRadixNode, a: int) = return else: assert(false) -proc contains*(r: PRadixNode, a: TAddress): bool = +proc contains*(r: PRadixNode, a: ByteAddress): bool = if r == nil: return false var x = searchInner(r, a shr 24 and 0xff) if x == nil: return false @@ -88,7 +88,7 @@ proc contains*(r: PRadixNode, a: TAddress): bool = if x == nil: return false return searchLeaf(x, a and 0xff) -proc excl*(r: PRadixNode, a: TAddress): bool = +proc excl*(r: PRadixNode, a: ByteAddress): bool = if r == nil: return false var x = searchInner(r, a shr 24 and 0xff) if x == nil: return false @@ -167,10 +167,10 @@ proc addInner(r: var PRadixNode, a: int, d: int): bool = return addInner(x.b[k], a, d-8) else: assert(false) -proc incl*(r: var PRadixNode, a: TAddress) {.inline.} = +proc incl*(r: var PRadixNode, a: ByteAddress) {.inline.} = discard addInner(r, a, 24) -proc testOrIncl*(r: var PRadixNode, a: TAddress): bool {.inline.} = +proc testOrIncl*(r: var PRadixNode, a: ByteAddress): bool {.inline.} = return addInner(r, a, 24) iterator innerElements(r: PRadixNode): tuple[prefix: int, n: PRadixNode] = @@ -204,7 +204,7 @@ iterator leafElements(r: PRadixNode): int = yield ze(r.keys[i]) else: assert(false) -iterator elements*(r: PRadixNode): TAddress {.inline.} = +iterator elements*(r: PRadixNode): ByteAddress {.inline.} = for p1, n1 in innerElements(r): for p2, n2 in innerElements(n1): for p3, n3 in innerElements(n2): @@ -297,7 +297,7 @@ when false: result = ze(r.keys[i.x]) inc(i.x) - iterator elements(r: PRadixNode): TAddress {.inline.} = + iterator elements(r: PRadixNode): ByteAddress {.inline.} = var a, b, c, d: TRadixIter init(a, r) diff --git a/tests/misc/treadln.nim b/tests/misc/treadln.nim index 1117ab5f9..1edbea992 100644 --- a/tests/misc/treadln.nim +++ b/tests/misc/treadln.nim @@ -2,11 +2,11 @@ # Macintosh, Unix or Windows text format. var - inp: TFile + inp: File line: string if open(inp, "readme.txt"): - while not EndOfFile(inp): + while not endOfFile(inp): line = readLine(inp) echo("#" & line & "#") close(inp) diff --git a/tests/misc/tsimplesort.nim b/tests/misc/tsimplesort.nim index 0167ca78a..c282b3445 100644 --- a/tests/misc/tsimplesort.nim +++ b/tests/misc/tsimplesort.nim @@ -4,11 +4,7 @@ discard """ import hashes, math - -when defined(shallowADT): - {.pragma: myShallow, shallow.} -else: - {.pragma: myShallow.} +{.pragma: myShallow.} type TSlotEnum = enum seEmpty, seFilled, seDeleted @@ -63,7 +59,7 @@ template rawInsertImpl() = data[h].val = val data[h].slot = seFilled -proc RawGet[A, B](t: TTable[A, B], key: A): int = +proc rawGet[A, B](t: TTable[A, B], key: A): int = rawGetImpl() proc `[]`*[A, B](t: TTable[A, B], key: A): B = @@ -71,31 +67,31 @@ proc `[]`*[A, B](t: TTable[A, B], key: A): B = ## default empty value for the type `B` is returned ## and no exception is raised. One can check with ``hasKey`` whether the key ## exists. - var index = RawGet(t, key) + var index = rawGet(t, key) if index >= 0: result = t.data[index].val proc hasKey*[A, B](t: TTable[A, B], key: A): bool = ## returns true iff `key` is in the table `t`. result = rawGet(t, key) >= 0 -proc RawInsert[A, B](t: var TTable[A, B], data: var TKeyValuePairSeq[A, B], +proc rawInsert[A, B](t: var TTable[A, B], data: var TKeyValuePairSeq[A, B], key: A, val: B) = rawInsertImpl() -proc Enlarge[A, B](t: var TTable[A, B]) = +proc enlarge[A, B](t: var TTable[A, B]) = var n: TKeyValuePairSeq[A, B] newSeq(n, len(t.data) * growthFactor) for i in countup(0, high(t.data)): - if t.data[i].slot == seFilled: RawInsert(t, n, t.data[i].key, t.data[i].val) + if t.data[i].slot == seFilled: rawInsert(t, n, t.data[i].key, t.data[i].val) swap(t.data, n) -template PutImpl() = - var index = RawGet(t, key) +template putImpl() = + var index = rawGet(t, key) if index >= 0: t.data[index].val = val else: - if mustRehash(len(t.data), t.counter): Enlarge(t) - RawInsert(t, t.data, key, val) + if mustRehash(len(t.data), t.counter): enlarge(t) + rawInsert(t, t.data, key, val) inc(t.counter) proc `[]=`*[A, B](t: var TTable[A, B], key: A, val: B) = @@ -104,7 +100,7 @@ proc `[]=`*[A, B](t: var TTable[A, B], key: A, val: B) = proc del*[A, B](t: var TTable[A, B], key: A) = ## deletes `key` from hash table `t`. - var index = RawGet(t, key) + var index = rawGet(t, key) if index >= 0: t.data[index].slot = seDeleted dec(t.counter) @@ -183,24 +179,24 @@ proc hasKey*[A](t: TCountTable[A], key: A): bool = ## returns true iff `key` is in the table `t`. result = rawGet(t, key) >= 0 -proc RawInsert[A](t: TCountTable[A], data: var seq[tuple[key: A, val: int]], +proc rawInsert[A](t: TCountTable[A], data: var seq[tuple[key: A, val: int]], key: A, val: int) = var h: THash = hash(key) and high(data) while data[h].val != 0: h = nextTry(h, high(data)) data[h].key = key data[h].val = val -proc Enlarge[A](t: var TCountTable[A]) = +proc enlarge[A](t: var TCountTable[A]) = var n: seq[tuple[key: A, val: int]] newSeq(n, len(t.data) * growthFactor) for i in countup(0, high(t.data)): - if t.data[i].val != 0: RawInsert(t, n, t.data[i].key, t.data[i].val) + if t.data[i].val != 0: rawInsert(t, n, t.data[i].key, t.data[i].val) swap(t.data, n) proc `[]=`*[A](t: var TCountTable[A], key: A, val: int) = ## puts a (key, value)-pair into `t`. `val` has to be positive. assert val > 0 - PutImpl() + putImpl() proc initCountTable*[A](initialSize=64): TCountTable[A] = ## creates a new count table that is empty. `initialSize` needs to be @@ -224,11 +220,11 @@ proc inc*[A](t: var TCountTable[A], key: A, val = 1) = if index >= 0: inc(t.data[index].val, val) else: - if mustRehash(len(t.data), t.counter): Enlarge(t) - RawInsert(t, t.data, key, val) + if mustRehash(len(t.data), t.counter): enlarge(t) + rawInsert(t, t.data, key, val) inc(t.counter) -proc Smallest*[A](t: TCountTable[A]): tuple[key: A, val: int] = +proc smallest*[A](t: TCountTable[A]): tuple[key: A, val: int] = ## returns the largest (key,val)-pair. Efficiency: O(n) assert t.len > 0 var minIdx = 0 @@ -237,7 +233,7 @@ proc Smallest*[A](t: TCountTable[A]): tuple[key: A, val: int] = result.key = t.data[minIdx].key result.val = t.data[minIdx].val -proc Largest*[A](t: TCountTable[A]): tuple[key: A, val: int] = +proc largest*[A](t: TCountTable[A]): tuple[key: A, val: int] = ## returns the (key,val)-pair with the largest `val`. Efficiency: O(n) assert t.len > 0 var maxIdx = 0 diff --git a/tests/misc/tvarnums.nim b/tests/misc/tvarnums.nim index 4f99df8b9..b880cf006 100644 --- a/tests/misc/tvarnums.nim +++ b/tests/misc/tvarnums.nim @@ -74,7 +74,7 @@ proc toNum(b: TBuffer): int32 = while (ze(b[i]) and 128) != 0: inc(i) result = result or ((int32(ze(b[i])) and 127'i32) shl Shift) - Shift = shift + 7'i32 + Shift = Shift + 7'i32 if (ze(b[0]) and (1 shl 6)) != 0: # sign bit set? result = (not result) +% 1'i32 # this is the same as ``- result`` diff --git a/tests/modules/mexport2a.nim b/tests/modules/mexport2a.nim new file mode 100644 index 000000000..deaef8fa4 --- /dev/null +++ b/tests/modules/mexport2a.nim @@ -0,0 +1,5 @@ + +import mexport2b +export mexport2b +proc printAbc*() = echo "abc" + diff --git a/tests/modules/mexport2b.nim b/tests/modules/mexport2b.nim new file mode 100644 index 000000000..8ea6085de --- /dev/null +++ b/tests/modules/mexport2b.nim @@ -0,0 +1 @@ +proc printXyz*() = echo "xyz" diff --git a/tests/modules/texport2.nim b/tests/modules/texport2.nim new file mode 100644 index 000000000..0826eec9d --- /dev/null +++ b/tests/modules/texport2.nim @@ -0,0 +1,10 @@ +# bug #1595 + +import mexport2a + +proc main() = + echo "Import Test, two lines should follow. One with abc and one with xyz." + printAbc() + printXyz() + +main() diff --git a/tests/modules/tmismatchedvisibility.nim b/tests/modules/tmismatchedvisibility.nim new file mode 100644 index 000000000..6f2f79282 --- /dev/null +++ b/tests/modules/tmismatchedvisibility.nim @@ -0,0 +1,9 @@ +discard """ + line: 8 + errormsg: "public implementation 'tmismatchedvisibility.foo(a: int): int' has non-public forward declaration in tmismatchedvisibility.nim(6,5)" +""" + +proc foo(a: int): int + +proc foo*(a: int): int = + result = a + a \ No newline at end of file diff --git a/tests/objects/tobjcov.nim b/tests/objects/tobjcov.nim index fc44edf8e..8391727f2 100644 --- a/tests/objects/tobjcov.nim +++ b/tests/objects/tobjcov.nim @@ -9,7 +9,7 @@ type proc ap(x: var TA) = x.a = -1 proc bp(x: var TB) = x.b[high(x.b)] = -1 -# in Nimrod proc (x: TB) is compatible to proc (x: TA), +# in Nim proc (x: TB) is compatible to proc (x: TA), # but this is not type safe: var f = cast[proc (x: var TA) {.nimcall.}](bp) var a: TA diff --git a/tests/objvariant/tyaoption.nim b/tests/objvariant/tyaoption.nim index 635e60bb8..7a29b8008 100644 --- a/tests/objvariant/tyaoption.nim +++ b/tests/objvariant/tyaoption.nim @@ -7,7 +7,7 @@ some(10)''' import strutils type Option[A] = object - case isDefined*: Bool + case isDefined*: bool of true: value*: A of false: @@ -19,7 +19,7 @@ proc some[A](value: A): Option[A] = proc none[A](): Option[A] = Option[A](isDefined: false) -proc `$`[A](o: Option[A]): String = +proc `$`[A](o: Option[A]): string = if o.isDefined: "some($1)" % [$o.value] else: @@ -27,14 +27,14 @@ proc `$`[A](o: Option[A]): String = let x = some("str") let y = some(5) -let z = none[Int]() +let z = none[int]() echo x, ", ", y, ", ", z -proc intOrString[A : Int | String](o: Option[A]): Option[A] = - when A is Int: +proc intOrString[A : int | string](o: Option[A]): Option[A] = + when A is int: some(o.value + 5) - elif A is String: + elif A is string: some(o.value & "!") else: o diff --git a/tests/overflw/toverflw.nim b/tests/overflw/toverflw.nim index cd7b65acf..fbe0d0a38 100644 --- a/tests/overflw/toverflw.nim +++ b/tests/overflw/toverflw.nim @@ -2,7 +2,7 @@ discard """ file: "toverflw.nim" output: "the computation overflowed" """ -# Tests nimrod's ability to detect overflows +# Tests nim's ability to detect overflows {.push overflowChecks: on.} @@ -12,7 +12,7 @@ a = high(int) b = -2 try: writeln(stdout, b - a) -except EOverflow: +except OverflowError: writeln(stdout, "the computation overflowed") {.pop.} # overflow check diff --git a/tests/overflw/toverflw2.nim b/tests/overflw/toverflw2.nim index f7fe3d574..75bd4cdf5 100644 --- a/tests/overflw/toverflw2.nim +++ b/tests/overflw/toverflw2.nim @@ -1,6 +1,6 @@ discard """ file: "toverflw2.nim" - outputsub: "Error: unhandled exception: over- or underflow [EOverflow]" + outputsub: "Error: unhandled exception: over- or underflow [OverflowError]" exitcode: "1" """ var a : int32 = 2147483647 diff --git a/tests/parallel/nimrod.cfg b/tests/parallel/nim.cfg index b81c89721..b81c89721 100644 --- a/tests/parallel/nimrod.cfg +++ b/tests/parallel/nim.cfg diff --git a/tests/parallel/tdeepcopy2.nim b/tests/parallel/tdeepcopy2.nim new file mode 100644 index 000000000..748ef4d9b --- /dev/null +++ b/tests/parallel/tdeepcopy2.nim @@ -0,0 +1,35 @@ +discard """ + output: '''called deepCopy for int +called deepCopy for int +done999 999 +""" + +import threadpool + + +type + Bar[T] = object + x: T + +proc deepCopy[T](b: ref Bar[T]): ref Bar[T] {.override.} = + result.new + result.x = b.x + when T is int: + echo "called deepCopy for int" + else: + echo "called deepCopy for something else" + +proc foo(b: ref Bar[int]): int = 999 + +# test that the disjoint checker deals with 'a = spawn f(); g = spawn f()': + +proc main = + var dummy: ref Bar[int] + new(dummy) + dummy.x = 44 + parallel: + let f = spawn foo(dummy) + let b = spawn foo(dummy) + echo "done", f, " ", b + +main() diff --git a/tests/parallel/tflowvar.nim b/tests/parallel/tflowvar.nim index 77fab14b5..fd3aa326e 100644 --- a/tests/parallel/tflowvar.nim +++ b/tests/parallel/tflowvar.nim @@ -1,11 +1,14 @@ discard """ - output: '''foobarfoobarbazbearbazbear''' - cmd: "nimrod $target --threads:on $options $file" + output: '''foobarfoobar +bazbearbazbear + +1''' + cmd: "nim $target --threads:on $options $file" """ import threadpool -proc computeSomething(a, b: string): string = a & b & a & b +proc computeSomething(a, b: string): string = a & b & a & b & "\n" proc main = let fvA = spawn computeSomething("foo", "bar") @@ -15,3 +18,19 @@ proc main = main() sync() + + +type + TIntSeq = seq[int] + +proc t(): TIntSeq = + result = @[1] + +proc p(): int = + var a: FlowVar[TIntSeq] + parallel: + var aa = spawn t() + a = aa + result = (^a)[0] + +echo p() diff --git a/tests/parallel/tguard1.nim b/tests/parallel/tguard1.nim new file mode 100644 index 000000000..d96e17589 --- /dev/null +++ b/tests/parallel/tguard1.nim @@ -0,0 +1,37 @@ + +when false: + template lock(a, b: ptr TLock; body: stmt) = + if cast[ByteAddress](a) < cast[ByteAddress](b): + pthread_mutex_lock(a) + pthread_mutex_lock(b) + else: + pthread_mutex_lock(b) + pthread_mutex_lock(a) + {.locks: [a, b].}: + try: + body + finally: + pthread_mutex_unlock(a) + pthread_mutex_unlock(b) + +type + ProtectedCounter[T] = object + i {.guard: L.}: T + L: int + +var + c: ProtectedCounter[int] + +c.i = 89 + +template atomicRead(L, x): expr = + {.locks: [L].}: + x + +proc main = + {.locks: [c.L].}: + inc c.i + discard + echo(atomicRead(c.L, c.i)) + +main() diff --git a/tests/parallel/tguard2.nim b/tests/parallel/tguard2.nim new file mode 100644 index 000000000..b69ea3371 --- /dev/null +++ b/tests/parallel/tguard2.nim @@ -0,0 +1,27 @@ +discard """ + errormsg: "unguarded access: c.i" + line: 25 +""" + +type + ProtectedCounter[T] = object + i {.guard: L.}: T + L: int + +var + c: ProtectedCounter[int] + +c.i = 89 + +template atomicRead(L, x): expr = + {.locks: [L].}: + x + +proc main = + {.locks: [c.L].}: + inc c.i + discard + echo(atomicRead(c.L, c.i)) + echo c.i + +main() diff --git a/tests/parallel/tlet_spawn.nim b/tests/parallel/tlet_spawn.nim new file mode 100644 index 000000000..463ee1a47 --- /dev/null +++ b/tests/parallel/tlet_spawn.nim @@ -0,0 +1,14 @@ + +import threadpool + +proc foo(): int = 999 + +# test that the disjoint checker deals with 'a = spawn f(); g = spawn f()': + +proc main = + parallel: + let f = spawn foo() + let b = spawn foo() + echo "done", f, " ", b + +main() diff --git a/tests/parallel/tsysspawn.nim b/tests/parallel/tsysspawn.nim index fc7921b0e..7244a5ee6 100644 --- a/tests/parallel/tsysspawn.nim +++ b/tests/parallel/tsysspawn.nim @@ -1,7 +1,7 @@ discard """ output: '''4 8''' - cmd: "nimrod $target --threads:on $options $file" + cmd: "nim $target --threads:on $options $file" """ import threadpool diff --git a/tests/parallel/tsysspawnbadarg.nim b/tests/parallel/tsysspawnbadarg.nim index ad798a7d3..2d3ffd241 100644 --- a/tests/parallel/tsysspawnbadarg.nim +++ b/tests/parallel/tsysspawnbadarg.nim @@ -1,7 +1,7 @@ discard """ line: 9 errormsg: "'spawn' takes a call expression" - cmd: "nimrod $target --threads:on $options $file" + cmd: "nim $target --threads:on $options $file" """ import threadpool diff --git a/tests/procvar/tprocvars.nim b/tests/procvar/tprocvars.nim index dc7592526..50d5d29f2 100644 --- a/tests/procvar/tprocvars.nim +++ b/tests/procvar/tprocvars.nim @@ -1,6 +1,6 @@ -proc doSomething(v: Int, x: proc(v:Int):Int): Int = return x(v) -proc doSomething(v: Int, x: proc(v:Int)) = x(v) +proc doSomething(v: int, x: proc(v:int):int): int = return x(v) +proc doSomething(v: int, x: proc(v:int)) = x(v) -echo doSomething(10, proc(v: Int): Int = return v div 2) +echo doSomething(10, proc(v: int): int = return v div 2) diff --git a/tests/range/tsubrange2.nim b/tests/range/tsubrange2.nim index d14111bb9..759d16b9c 100644 --- a/tests/range/tsubrange2.nim +++ b/tests/range/tsubrange2.nim @@ -1,6 +1,6 @@ discard """ file: "tsubrange2.nim" - outputsub: "value out of range: 50 [EOutOfRange]" + outputsub: "value out of range: 50 [RangeError]" exitcode: "1" """ diff --git a/tests/range/tsubrange3.nim b/tests/range/tsubrange3.nim index 9afb5018b..600161cfd 100644 --- a/tests/range/tsubrange3.nim +++ b/tests/range/tsubrange3.nim @@ -1,6 +1,6 @@ discard """ file: "tsubrange.nim" - outputsub: "value out of range: 50 [EOutOfRange]" + outputsub: "value out of range: 50 [RangeError]" exitcode: "1" """ @@ -16,4 +16,3 @@ var r = y #p y - diff --git a/tests/showoff/thtml2.nim b/tests/showoff/thtml2.nim index 8a451ebf1..faeb4e50d 100644 --- a/tests/showoff/thtml2.nim +++ b/tests/showoff/thtml2.nim @@ -1,5 +1,5 @@ discard """ - output: "<html><head><title>now look at this</title></head><body><ul><li>Nimrod is quite capable</li></ul></body></html>" + output: "<html><head><title>now look at this</title></head><body><ul><li>Nim is quite capable</li></ul></body></html>" """ import strutils @@ -32,6 +32,6 @@ html mainPage: title "now look at this" body: ul: - li "Nimrod is quite capable" + li "Nim is quite capable" echo mainPage() diff --git a/tests/stdlib/techo.nim b/tests/stdlib/techo.nim index 0fa4b5fe0..9cef9205f 100644 --- a/tests/stdlib/techo.nim +++ b/tests/stdlib/techo.nim @@ -1,3 +1,3 @@ -# Simplest Nimrod program +# Simplest Nim program echo "Hello, World!" diff --git a/tests/stdlib/tircbot.nim b/tests/stdlib/tircbot.nim index f0417c7ac..b91300762 100644 --- a/tests/stdlib/tircbot.nim +++ b/tests/stdlib/tircbot.nim @@ -191,7 +191,7 @@ type const ircServer = "irc.freenode.net" - joinChans = @["#nimrod"] + joinChans = @["#nim"] botNickname = "NimBot" proc setSeen(d: TDb, s: TSeen) = @@ -271,7 +271,7 @@ proc handleWebMessage(state: PState, line: string) = message.add("-" & $commit["removed"].len & "]: ") message.add(limitCommitMsg(commit["message"].str)) - # Send message to #nimrod. + # Send message to #nim. state.ircClient.privmsg(joinChans[0], message) elif json.hasKey("redisinfo"): assert json["redisinfo"].hasKey("port") @@ -420,7 +420,7 @@ proc handleIrc(irc: PAsyncIRC, event: TIRCEvent, state: PState) = seenNick.msg = msg state.database.setSeen(seenNick) of MNick: - createSeen(PSeenNick, event.nick, "#nimrod") + createSeen(PSeenNick, event.nick, "#nim") seenNick.newNick = event.params[0] state.database.setSeen(seenNick) else: diff --git a/tests/stdlib/tpegs.nim b/tests/stdlib/tpegs.nim index 6e488bab4..e5353e4ff 100644 --- a/tests/stdlib/tpegs.nim +++ b/tests/stdlib/tpegs.nim @@ -851,7 +851,7 @@ template `=~`*(s: string, pattern: TPeg): expr = ## This calls ``match`` with an implicit declared ``matches`` array that ## can be used in the scope of the ``=~`` call: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## ## if line =~ peg"\s* {\w+} \s* '=' \s* {\w+}": ## # matches a key=value pair: @@ -897,12 +897,12 @@ proc replacef*(s: string, sub: TPeg, by: string): string {. ## Replaces `sub` in `s` by the string `by`. Captures can be accessed in `by` ## with the notation ``$i`` and ``$#`` (see strutils.`%`). Examples: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## "var1=key; var2=key2".replace(peg"{\ident}'='{\ident}", "$1<-$2$2") ## ## Results in: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## ## "var1<-keykey; val2<-key2key2" result = "" @@ -979,13 +979,13 @@ iterator split*(s: string, sep: TPeg): string = ## Substrings are separated by the PEG `sep`. ## Examples: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## for word in split("00232this02939is39an22example111", peg"\d+"): ## writeln(stdout, word) ## ## Results in: ## - ## .. code-block:: nimrod + ## .. code-block:: nim ## "this" ## "is" ## "an" diff --git a/tests/stdlib/tunidecode.nim b/tests/stdlib/tunidecode.nim index 647858825..689453c76 100644 --- a/tests/stdlib/tunidecode.nim +++ b/tests/stdlib/tunidecode.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nimrod $target --hints:on -d:embedUnidecodeTable $options $file" + cmd: "nim $target --hints:on -d:embedUnidecodeTable $options $file" output: "Ausserst" """ diff --git a/tests/stdlib/txmlgen.nim b/tests/stdlib/txmlgen.nim index 917427abc..fa1dffe56 100644 --- a/tests/stdlib/txmlgen.nim +++ b/tests/stdlib/txmlgen.nim @@ -1,11 +1,11 @@ discard """ file: "txmlgen.nim" - output: "<h1><a href=\"http://force7.de/nimrod\">Nimrod</a></h1>" + output: "<h1><a href=\"http://force7.de/nim\">Nim</a></h1>" """ import htmlgen -var nim = "Nimrod" -echo h1(a(href="http://force7.de/nimrod", nim)) +var nim = "Nim" +echo h1(a(href="http://force7.de/nim", nim)) diff --git a/tests/stdlib/txmltree.nim b/tests/stdlib/txmltree.nim index 931871f15..bfe2dc94a 100644 --- a/tests/stdlib/txmltree.nim +++ b/tests/stdlib/txmltree.nim @@ -5,9 +5,9 @@ discard """ import xmltree, strtabs -var x = <>a(href="nimrod.de", newText("www.nimrod-test.de")) +var x = <>a(href="nim.de", newText("www.nim-test.de")) -echo($x == "<a href=\"nimrod.de\">www.nimrod-test.de</a>") +echo($x == "<a href=\"nim.de\">www.nim-test.de</a>") diff --git a/tests/table/ttables.nim b/tests/table/ttables.nim index 60446b5a3..de4aaed5e 100644 --- a/tests/table/ttables.nim +++ b/tests/table/ttables.nim @@ -84,7 +84,7 @@ block orderedTableTest1: block countTableTest1: var s = data.toTable var t = initCountTable[string]() - for k in s.Keys: t.inc(k) + for k in s.keys: t.inc(k) for k in t.keys: assert t[k] == 1 t.inc("90", 3) t.inc("12", 2) diff --git a/tests/template/t_otemplates.nim b/tests/template/t_otemplates.nim index 7de728ab2..1a9075d20 100644 --- a/tests/template/t_otemplates.nim +++ b/tests/template/t_otemplates.nim @@ -3,8 +3,8 @@ discard """ """ # Ref: -# http://nimrod-lang.org/macros.html -# http://nimrod-lang.org/parseutils.html +# http://nim-lang.org/macros.html +# http://nim-lang.org/parseutils.html # Imports @@ -313,7 +313,7 @@ proc parse_until_symbol(node: PNimrodNode, value: string, index: var int): bool proc parse_template(node: PNimrodNode, value: string) = ## Parses through entire template, outputing valid - ## Nimrod code into the input `node` AST. + ## Nim code into the input `node` AST. var index = 0 while index < value.len and parse_until_symbol(node, value, index): nil diff --git a/tests/template/tissue993.nim b/tests/template/tissue993.nim index d39f43942..dae9df683 100644 --- a/tests/template/tissue993.nim +++ b/tests/template/tissue993.nim @@ -1,5 +1,5 @@ -type pnode* = ref object of tobject +type PNode* = ref object of RootObj template litNode (name, ty): stmt = type name* = ref object of PNode @@ -8,7 +8,7 @@ litNode PIntNode, int import json -template withKey*(j: PJsonNode; key: string; varname: expr; +template withKey*(j: JsonNode; key: string; varname: expr; body:stmt): stmt {.immediate.} = if j.hasKey(key): let varname{.inject.}= j[key] diff --git a/tests/testament/backend.nim b/tests/testament/backend.nim index 5199bb9d6..c7122e1b2 100644 --- a/tests/testament/backend.nim +++ b/tests/testament/backend.nim @@ -1,6 +1,6 @@ # # -# The Nimrod Tester +# The Nim Tester # (c) Copyright 2014 Andreas Rumpf # # Look at license.txt for more info. diff --git a/tests/testament/caasdriver.nim b/tests/testament/caasdriver.nim index ddfe88273..8f2eec33b 100644 --- a/tests/testament/caasdriver.nim +++ b/tests/testament/caasdriver.nim @@ -9,7 +9,7 @@ type TRunMode = enum ProcRun, CaasRun, SymbolProcRun - TNimrodSession* = object + NimSession* = object nim: PProcess # Holds the open process for CaasRun sessions, nil otherwise. mode: TRunMode # Stores the type of run mode the session was started with. lastOutput: string # Preserves the last output, needed for ProcRun mode. @@ -26,15 +26,15 @@ const var TesterDir = getAppDir() / ".." - NimrodBin = TesterDir / "../bin/nimrod" + NimBin = TesterDir / "../bin/nim" -proc replaceVars(session: var TNimrodSession, text: string): string = +proc replaceVars(session: var NimSession, text: string): string = result = text.replace(filenameReplaceVar, session.filename) result = result.replace(moduleReplaceVar, session.modname) result = result.replace(silentReplaceVar, silentReplaceText) -proc startNimrodSession(project, script: string, mode: TRunMode): - TNimrodSession = +proc startNimSession(project, script: string, mode: TRunMode): + NimSession = let (dir, name, ext) = project.splitFile result.mode = mode result.lastOutput = "" @@ -50,10 +50,10 @@ proc startNimrodSession(project, script: string, mode: TRunMode): removeDir(nimcacheDir / "nimcache") if mode == CaasRun: - result.nim = startProcess(NimrodBin, workingDir = dir, + result.nim = startProcess(NimBin, workingDir = dir, args = ["serve", "--server.type:stdin", name]) -proc doCaasCommand(session: var TNimrodSession, command: string): string = +proc doCaasCommand(session: var NimSession, command: string): string = assert session.mode == CaasRun session.nim.inputStream.write(session.replaceVars(command) & "\n") session.nim.inputStream.flush @@ -69,11 +69,11 @@ proc doCaasCommand(session: var TNimrodSession, command: string): string = result = "FAILED TO EXECUTE: " & command & "\n" & result break -proc doProcCommand(session: var TNimrodSession, command: string): string = +proc doProcCommand(session: var NimSession, command: string): string = assert session.mode == ProcRun or session.mode == SymbolProcRun except: result = "FAILED TO EXECUTE: " & command & "\n" & result var - process = startProcess(NimrodBin, args = session.replaceVars(command).split) + process = startProcess(NimBin, args = session.replaceVars(command).split) stream = outputStream(process) line = TaintedString("") @@ -84,7 +84,7 @@ proc doProcCommand(session: var TNimrodSession, command: string): string = process.close() -proc doCommand(session: var TNimrodSession, command: string) = +proc doCommand(session: var NimSession, command: string) = if session.mode == CaasRun: if not session.nim.running: session.lastOutput = "FAILED TO EXECUTE: " & command & "\n" & @@ -102,7 +102,7 @@ proc doCommand(session: var TNimrodSession, command: string) = session.lastOutput = doProcCommand(session, command & " " & session.filename) -proc close(session: var TNimrodSession) {.destructor.} = +proc close(session: var NimSession) {.destructor.} = if session.mode == CaasRun: session.nim.close @@ -114,7 +114,7 @@ proc doScenario(script: string, output: PStream, mode: TRunMode, verbose: bool): if f.readLine(project): var - s = startNimrodSession(script.parentDir / project.string, script, mode) + s = startNimSession(script.parentDir / project.string, script, mode) tline = TaintedString("") ln = 1 diff --git a/tests/testament/categories.nim b/tests/testament/categories.nim index 02f7dc1d7..566a74cab 100644 --- a/tests/testament/categories.nim +++ b/tests/testament/categories.nim @@ -1,6 +1,6 @@ # # -# Nimrod Tester +# Nim Tester # (c) Copyright 2014 Andreas Rumpf # # See the file "copying.txt", included in this @@ -20,7 +20,7 @@ const proc delNimCache() = try: removeDir(nimcacheDir) - except EOS: + except OSError: echo "[Warning] could not delete: ", nimcacheDir proc runRodFiles(r: var TResults, cat: Category, options: string) = @@ -71,7 +71,7 @@ proc compileRodFiles(r: var TResults, cat: Category, options: string) = proc safeCopyFile(src, dest: string) = try: copyFile(src, dest) - except EOS: + except OSError: echo "[Warning] could not copy: ", src, " to ", dest proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = @@ -87,7 +87,7 @@ proc runBasicDLLTest(c, r: var TResults, cat: Category, options: string) = else: # posix relies on crappy LD_LIBRARY_PATH (ugh!): var libpath = getenv"LD_LIBRARY_PATH".string - if peg"\i '/nimrod' (!'/')* '/lib'" notin libpath: + if peg"\i '/nim' (!'/')* '/lib'" notin libpath: echo "[Warning] insufficient LD_LIBRARY_PATH" var serverDll = DynlibFormat % "server" safeCopyFile("tests/dll" / serverDll, "lib" / serverDll) @@ -192,9 +192,9 @@ proc jsTests(r: var TResults, cat: Category, options: string) = # testSpec(r, t, options) proc findMainFile(dir: string): string = - # finds the file belonging to ".nimrod.cfg"; if there is no such file + # finds the file belonging to ".nim.cfg"; if there is no such file # it returns the some ".nim" file if there is only one: - const cfgExt = ".nimrod.cfg" + const cfgExt = ".nim.cfg" result = "" var nimFiles = 0 for kind, file in os.walkDir(dir): @@ -236,8 +236,8 @@ let packageDir = babelDir / "pkgs" packageIndex = babelDir / "packages.json" -proc waitForExitEx(p: PProcess): int = - var outp: PStream = outputStream(p) +proc waitForExitEx(p: Process): int = + var outp = outputStream(p) var line = newStringOfCap(120).TaintedString while true: if outp.readLine(line): @@ -250,7 +250,7 @@ proc waitForExitEx(p: PProcess): int = proc getPackageDir(package: string): string = ## TODO - Replace this with dom's version comparison magic. var commandOutput = execCmdEx("babel path $#" % package) - if commandOutput.exitCode != quitSuccess: + if commandOutput.exitCode != QuitSuccess: return "" else: result = commandOutput[0].string @@ -278,7 +278,7 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) = echo("[Warning] - Cannot run babel tests: Babel binary not found.") return - if execCmd("$# update" % babelExe) == quitFailure: + if execCmd("$# update" % babelExe) == QuitFailure: echo("[Warning] - Cannot run babel tests: Babel update failed.") return @@ -291,7 +291,7 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) = installProcess = startProcess(babelExe, "", ["install", "-y", name]) installStatus = waitForExitEx(installProcess) installProcess.close - if installStatus != quitSuccess: + if installStatus != QuitSuccess: r.addResult(test, "", "", reInstallFailed) continue @@ -301,11 +301,11 @@ proc testBabelPackages(r: var TResults, cat: Category, filter: PackageFilter) = buildProcess = startProcess(babelExe, buildPath, ["build"]) buildStatus = waitForExitEx(buildProcess) buildProcess.close - if buildStatus != quitSuccess: + if buildStatus != QuitSuccess: r.addResult(test, "", "", reBuildFailed) r.addResult(test, "", "", reSuccess) r.addResult(packageFileTest, "", "", reSuccess) - except EJsonParsingError: + except JsonParsingError: echo("[Warning] - Cannot run babel tests: Invalid package file.") r.addResult(packageFileTest, "", "", reBuildFailed) diff --git a/tests/testament/htmlgen.nim b/tests/testament/htmlgen.nim index b91475aee..b9eda5383 100644 --- a/tests/testament/htmlgen.nim +++ b/tests/testament/htmlgen.nim @@ -1,6 +1,6 @@ # # -# Nimrod Tester +# Nim Tester # (c) Copyright 2014 Andreas Rumpf # # See the file "copying.txt", included in this @@ -107,7 +107,7 @@ div.tabContent.hide { display: none; } HtmlEnd = "</body></html>" proc td(s: string): string = - result = "<td>" & s.substr(0, 200).XMLEncode & "</td>" + result = "<td>" & s.substr(0, 200).xmlEncode & "</td>" proc getCommit(db: TDbConn, c: int): string = var commit = c diff --git a/tests/testament/specs.nim b/tests/testament/specs.nim index 184f07c51..37fe8cfee 100644 --- a/tests/testament/specs.nim +++ b/tests/testament/specs.nim @@ -1,6 +1,6 @@ # # -# Nimrod Tester +# Nim Tester # (c) Copyright 2014 Andreas Rumpf # # See the file "copying.txt", included in this @@ -10,7 +10,7 @@ import parseutils, strutils, os, osproc, streams, parsecfg const - cmdTemplate* = r"nimrod $target --hints:on $options $file" + cmdTemplate* = r"nim $target --hints:on $options $file" type TTestAction* = enum @@ -18,7 +18,7 @@ type actionRun = "run" actionReject = "reject" TResultEnum* = enum - reNimrodcCrash, # nimrod compiler seems to have crashed + reNimcCrash, # nim compiler seems to have crashed reMsgsDiffer, # error messages differ reFilesDiffer, # expected and given filenames differ reLinesDiffer, # expected and given line numbers differ @@ -59,7 +59,7 @@ when not declared(parseCfgBool): 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) + else: raise newException(ValueError, "cannot interpret as a bool: " & s) proc extractSpec(filename: string): string = const tripleQuote = "\"\"\"" @@ -78,7 +78,7 @@ when not defined(nimhygiene): template parseSpecAux(fillResult: stmt) {.immediate.} = var ss = newStringStream(extractSpec(filename)) - var p {.inject.}: TCfgParser + var p {.inject.}: CfgParser open(p, ss, filename, 1) while true: var e {.inject.} = next(p) diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim index fc6b4ff95..b74fa99c8 100644 --- a/tests/testament/tester.nim +++ b/tests/testament/tester.nim @@ -1,13 +1,13 @@ # # -# Nimrod Tester +# Nim Tester # (c) Copyright 2014 Andreas Rumpf # # See the file "copying.txt", included in this # distribution, for details about the copyright. # -## This program verifies Nimrod against the testcases. +## This program verifies Nim against the testcases. import parseutils, strutils, pegs, os, osproc, streams, parsecfg, json, @@ -146,9 +146,9 @@ proc codegenCheck(test: TTest, check: string, given: var TSpec) = let contents = readFile(genFile).string if contents.find(check.peg) < 0: given.err = reCodegenFailure - except EInvalidValue: + except ValueError: given.err = reInvalidPeg - except EIO: + except IOError: given.err = reCodeNotFound proc makeDeterministic(s: string): string = @@ -193,7 +193,7 @@ proc testSpec(r: var TResults, test: TTest) = return var (buf, exitCode) = execCmdEx( (if test.target == targetJS: "nodejs " else: "") & exeFile) - if exitCode != expected.ExitCode: + if exitCode != expected.exitCode: r.addResult(test, "exitcode: " & $expected.exitCode, "exitcode: " & $exitCode, reExitCodesDiffer) else: @@ -246,15 +246,15 @@ proc main() = if p.kind == cmdLongoption: case p.key.string.normalize of "print", "verbose": optPrintResults = true - else: quit usage + else: quit Usage p.next() - if p.kind != cmdArgument: quit usage + if p.kind != cmdArgument: quit Usage var action = p.key.string.normalize p.next() var r = initResults() case action of "all": - let testsDir = "tests" & dirSep + let testsDir = "tests" & DirSep for kind, dir in walkDir(testsDir): assert testsDir.startsWith(testsDir) let cat = dir[testsDir.len .. -1] @@ -272,7 +272,7 @@ proc main() = generateHtml(resultsFile, commit) generateJson(jsonFile, commit) else: - quit usage + quit Usage if optPrintResults: if action == "html": openDefaultBrowser(resultsFile) @@ -280,6 +280,6 @@ proc main() = backend.close() if paramCount() == 0: - quit usage + quit Usage main() diff --git a/tests/threads/nimrod.cfg b/tests/threads/nim.cfg index b81c89721..b81c89721 100644 --- a/tests/threads/nimrod.cfg +++ b/tests/threads/nim.cfg diff --git a/tests/threads/tthreadanalysis.nim b/tests/threads/tthreadanalysis.nim index 37369b79c..b222f15a9 100644 --- a/tests/threads/tthreadanalysis.nim +++ b/tests/threads/tthreadanalysis.nim @@ -2,7 +2,7 @@ discard """ outputsub: "101" errormsg: "'threadFunc' is not GC-safe" line: 39 - cmd: "nimrod $target --hints:on --threads:on $options $file" + cmd: "nim $target --hints:on --threads:on $options $file" """ import os diff --git a/tests/threads/tthreadanalysis2.nim b/tests/threads/tthreadanalysis2.nim index bcc09db98..d5b2cd430 100644 --- a/tests/threads/tthreadanalysis2.nim +++ b/tests/threads/tthreadanalysis2.nim @@ -2,7 +2,7 @@ discard """ file: "tthreadanalysis2.nim" line: 37 errormsg: "'threadFunc' is not GC-safe" - cmd: "nimrod $target --hints:on --threads:on $options $file" + cmd: "nim $target --hints:on --threads:on $options $file" """ import os diff --git a/tests/threads/tthreadheapviolation1.nim b/tests/threads/tthreadheapviolation1.nim index e0629ed08..94e1b64db 100644 --- a/tests/threads/tthreadheapviolation1.nim +++ b/tests/threads/tthreadheapviolation1.nim @@ -1,7 +1,7 @@ discard """ line: 11 errormsg: "'horrible' is not GC-safe" - cmd: "nimrod $target --hints:on --threads:on $options $file" + cmd: "nim $target --hints:on --threads:on $options $file" """ var diff --git a/tests/trmacros/targlist.nim b/tests/trmacros/targlist.nim index e416edf0a..321b3d5d2 100644 --- a/tests/trmacros/targlist.nim +++ b/tests/trmacros/targlist.nim @@ -3,7 +3,7 @@ discard """ """ proc f(x: varargs[string, `$`]) = discard -template optF{f(X)}(x: varargs[expr]) = +template optF{f(x)}(x: varargs[expr]) = writeln(stdout, x) f 1, 2, false, 3, "ha" diff --git a/tests/typerel/tnoargopenarray.nim b/tests/typerel/tnoargopenarray.nim index 872ec86d2..20ebe5ecc 100644 --- a/tests/typerel/tnoargopenarray.nim +++ b/tests/typerel/tnoargopenarray.nim @@ -1,7 +1,7 @@ import db_sqlite -var db: TDbConn -Exec(db, sql"create table blabla()") +var db: DbConn +exec(db, sql"create table blabla()") diff --git a/tests/typerel/trectuple.nim b/tests/typerel/trectuple.nim index 7c43ec5ba..ebaaa2ea7 100644 --- a/tests/typerel/trectuple.nim +++ b/tests/typerel/trectuple.nim @@ -1,3 +1,7 @@ +discard """ + errormsg: "illegal recursion in type 'TNode'" + line: 8 +""" type PNode = ref TNode diff --git a/tests/typerel/trectuples.nim b/tests/typerel/trectuples.nim index c59cfe880..a74e4859c 100644 --- a/tests/typerel/trectuples.nim +++ b/tests/typerel/trectuples.nim @@ -1,3 +1,7 @@ +discard """ + errormsg: "illegal recursion in type 'Node'" + line: 6 +""" type Node = tuple[left: ref Node] diff --git a/tests/types/tforwty2.nim b/tests/types/tforwty2.nim index 5d15e112a..d103314c5 100644 --- a/tests/types/tforwty2.nim +++ b/tests/types/tforwty2.nim @@ -6,7 +6,7 @@ type PSDL_semaphore = ptr TSDL_semaphore TSDL_semaphore {.final.} = object - sem: Pointer #PSem_t; + sem: pointer #PSem_t; when not defined(USE_NAMED_SEMAPHORES): sem_data: int when defined(BROKEN_SEMGETVALUE): @@ -18,5 +18,5 @@ type PSDL_Sem = ptr TSDL_Sem TSDL_Sem = TSDL_Semaphore -proc SDL_CreateSemaphore(initial_value: Int32): PSDL_Sem {. +proc SDL_CreateSemaphore(initial_value: int32): PSDL_Sem {. importc: "SDL_CreateSemaphore".} diff --git a/tests/types/tillegaltyperecursion.nim b/tests/types/tillegaltyperecursion.nim index 114e4d08e..ebdbc1d13 100644 --- a/tests/types/tillegaltyperecursion.nim +++ b/tests/types/tillegaltyperecursion.nim @@ -1,5 +1,5 @@ discard """ - cmd: "nimrod $target --threads:on $options $file" + cmd: "nim $target --threads:on $options $file" errormsg: "illegal recursion in type 'TIRC'" line: 16 """ @@ -62,5 +62,5 @@ proc Connect*(irc: var TIRC, nick: string, host: string, port: int = 6667) = when isMainModule: var irc = initIRC() irc.Connect("AmryBot[Nim]","irc.freenode.net",6667) - irc.sendRaw("JOIN #nimrod") + irc.sendRaw("JOIN #nim") os.Sleep(4000) diff --git a/tests/types/tillrec.nim b/tests/types/tillrec.nim index 1d1ec0622..18757140a 100644 --- a/tests/types/tillrec.nim +++ b/tests/types/tillrec.nim @@ -11,6 +11,6 @@ type kids: seq[TLegal] TIllegal {.final.} = object #ERROR_MSG illegal recursion in type 'TIllegal' - y: Int + y: int x: array[0..3, TIllegal] diff --git a/tests/usingstmt/tusingstatement.nim b/tests/usingstmt/tusingstatement.nim index a33aced4c..b58478d74 100644 --- a/tests/usingstmt/tusingstatement.nim +++ b/tests/usingstmt/tusingstatement.nim @@ -9,7 +9,7 @@ import # This macro mimics the using statement from C# # # It's kept only as a test for the macro system -# Nimrod's destructors offer a mechanism for automatic +# Nim's destructors offer a mechanism for automatic # disposal of resources. # macro autoClose(e: expr): stmt {.immediate.} = diff --git a/tests/varstmt/tlet.nim b/tests/varstmt/tlet.nim index ba355c5d8..138f34433 100644 --- a/tests/varstmt/tlet.nim +++ b/tests/varstmt/tlet.nim @@ -10,7 +10,7 @@ proc main = elif name == "name": echo("Very funny, your name is name.") else: - Echo("Hi, ", name, "!") + echo("Hi, ", name, "!") let (x, y) = ("abc", name) echo y, x diff --git a/tests/vm/tasmparser.nim b/tests/vm/tasmparser.nim new file mode 100644 index 000000000..67313c858 --- /dev/null +++ b/tests/vm/tasmparser.nim @@ -0,0 +1,174 @@ + +# bug #1513 + +import os, parseutils, strutils, ropes, macros + +var + code {.compileTime.} = "" + start {.compileTime.} = 0 + line {.compileTime.} = 1 + cpp {.compileTime.} = "" + token {.compileTime.} = "" + +proc log (msg: string) {.compileTime.} = + echo msg + +proc asmx64 () {.compileTime} = + + #log "code = $1" % code + + const asmx64pre = "{.emit: \"\"\"{x64asm& x= *x64asm_ptr(`asm0`); try {" + const asmx64post = "} catch (Xbyak::Error e) { printf (\"asmx64 error: %s\\n\", e.what ()); }}\"\"\".} " + + const xp = "x." + + const symbolStart = { '_', 'a'..'z', 'A' .. 'Z' } + const symbol = { '0'..'9' } + symbolStart + const eolComment = { ';' } + const endOfLine = { '\l', '\r' } + const leadingWhiteSpace = { ' ' } + + const end_or_comment = endOfLine + eolComment + { '\0' } + + const passthrough_start = { '{', '`' } + const passthrough_end = { '}', '`', '\0' } + + const end_or_symbol_or_comment_or_passthrough = symbolStart + end_or_comment + passthrough_start + + + proc abortAsmParse (err:string) = + discard + + let codeLen = code.len + #let codeEnd = codeLen-1 + cpp.add asmx64pre + + #log "{$1}\n" % [code] + + type asmParseState = enum leading, mnemonic, betweenArguments, arguments, endCmd, skipToEndOfLine + + var state:asmParseState = leading + + proc checkEnd (err:string) = + let ch = code [start] + if int (ch) == 0: + abortAsmParse (err) + + proc get_passthrough () = + inc start + let prev_start = start + let prev_token = token + start += code.parseUntil (token, passthrough_end, start) + checkEnd ("Failed to find passthrough end delimiter from offset $1 for:$2\n$3" % [$prev_start, $(code [prev_start-prev_token.len..prev_start]), token[1..token.len-1]]) + inc start + cpp.add "`" + cpp.add token + cpp.add "`" + + var inparse = true + + proc checkCmdEnd () = + if codeLen == start: + state = endCmd + inparse = false + + while inparse: + checkCmdEnd () + + log ("state=$1 start=$2" % [$state, $start]) + + case state: + of leading: + + echo "b100 ", start + start += code.skipWhile (leadingWhiteSpace, start) + echo "b200 ", start + let ch = code [start] + if ch in endOfLine: + inc (line) + #echo "c100 ", start, ' ', code + start += code.skipWhile (endOfline, start) + #echo "c200 ", start, ' ', code + continue + elif ch in symbolStart: + state = mnemonic + elif ch in eolComment: + state = skipToEndOfLine + elif ch in passthrough_start: + get_passthrough () + echo "d100 ", start + start += code.parseUntil (token, end_or_symbol_or_comment_or_passthrough, start) + echo "d200 ", start + cpp.add token + state = mnemonic + elif int (ch) == 0: + break + else: + abortAsmParse ("after '$3' illegal character at offset $1: $2" % [$start, $(int (ch)), token]) + + of mnemonic: + echo "e100 ", start + start += code.parseWhile (token, symbol, start) + echo "e200 ", start + cpp.add xp + cpp.add token + cpp.add "(" + state = betweenArguments + + of betweenArguments: + let tmp = start + let rcode = code + start += rcode.parseUntil (token, end_or_symbol_or_comment_or_passthrough, tmp) + cpp.add token + + if codeLen <= start: + state = endCmd + continue + + let ch = code [start] + if ch in passthrough_start: + get_passthrough () + continue + if (ch in {'x', 'X'}) and ('0' == code [start-1]): + token = $(code [start]) + cpp.add token + inc start + continue + state = arguments + + of arguments: + if code [start] in end_or_comment: + state = endCmd + continue + start += code.parseWhile (token, symbol, start) + cpp.add xp + cpp.add token + state = betweenArguments + + of endCmd: + cpp.add ");\n" + state = skipToEndOfLine + + of skipToEndOfLine: + echo "a100 ", start + start += code.skipUntil (endOfLine, start) + echo "a200 ", start + start += code.skipWhile (endOfline, start) + echo "a300 ", start + inc line + state = leading + + cpp.add asmx64post + + echo ($cpp) + +macro asmx64x (code_in:expr) : stmt = + code = $code_in + echo ("code.len = $1, code = >>>$2<<<" % [$code.len, code]) + asmx64 () + discard result + +asmx64x """ + mov rax, {m} + ret +""" diff --git a/tests/vm/tcompiletimetable.nim b/tests/vm/tcompiletimetable.nim index f1d3ecd4e..df6ead56f 100644 --- a/tests/vm/tcompiletimetable.nim +++ b/tests/vm/tcompiletimetable.nim @@ -2,18 +2,19 @@ discard """ msg: '''2 3 4:2 - ''' +Got Hi +Got Hey''' """ # bug #404 -import macros, tables +import macros, tables, strtabs var ZOOT{.compileTime.} = initTable[int, int](2) var iii {.compiletime.} = 1 macro zoo:stmt= - zoot[iii] = iii*2 + ZOOT[iii] = iii*2 inc iii echo iii @@ -29,9 +30,7 @@ tupleUnpack # bug #903 -import strtabs - -var x {.compileTime.}: PStringTable +var x {.compileTime.}: StringTableRef macro addStuff(stuff, body: expr): stmt {.immediate.} = result = newNimNode(nnkStmtList) diff --git a/tests/vm/tconsteval.nim b/tests/vm/tconsteval.nim index 16fd8f4b8..96a1bafe8 100644 --- a/tests/vm/tconsteval.nim +++ b/tests/vm/tconsteval.nim @@ -6,7 +6,7 @@ import strutils const HelpText = """ +-----------------------------------------------------------------+ -| Maintenance program for Nimrod | +| Maintenance program for Nim | | Version $1| | (c) 2012 Andreas Rumpf | +-----------------------------------------------------------------+ @@ -19,13 +19,13 @@ Options: --help, -h shows this help and quits Possible Commands: boot [options] bootstraps with given command line options - clean cleans Nimrod project; removes generated files + clean cleans Nim project; removes generated files web generates the website csource [options] builds the C sources for installation zip builds the installation ZIP package inno builds the Inno Setup installer -""" % [NimrodVersion & repeatChar(44-len(NimrodVersion)), +""" % [NimVersion & repeatChar(44-len(NimVersion)), CompileDate, CompileTime] -echo helpText +echo HelpText diff --git a/tests/vm/trgba.nim b/tests/vm/trgba.nim index b1d94702f..22eec4d6e 100644 --- a/tests/vm/trgba.nim +++ b/tests/vm/trgba.nim @@ -6,20 +6,20 @@ discard """ #bug #1009 type - TAggRgba8* = array[4, Byte] + TAggRgba8* = array[4, byte] -template R*(self: TAggRgba8): Byte = self[0] -template G*(self: TAggRgba8): Byte = self[1] -template B*(self: TAggRgba8): Byte = self[2] -template A*(self: TAggRgba8): Byte = self[3] +template R*(self: TAggRgba8): byte = self[0] +template G*(self: TAggRgba8): byte = self[1] +template B*(self: TAggRgba8): byte = self[2] +template A*(self: TAggRgba8): byte = self[3] -template `R=`*(self: TAggRgba8, val: Byte) = +template `R=`*(self: TAggRgba8, val: byte) = self[0] = val -template `G=`*(self: TAggRgba8, val: Byte) = +template `G=`*(self: TAggRgba8, val: byte) = self[1] = val -template `B=`*(self: TAggRgba8, val: Byte) = +template `B=`*(self: TAggRgba8, val: byte) = self[2] = val -template `A=`*(self: TAggRgba8, val: Byte) = +template `A=`*(self: TAggRgba8, val: byte) = self[3] = val proc ABGR* (val: int| int64): TAggRgba8 = |