From 84378f3ddd46a32fc79db8842319130e16bf81db Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Tue, 5 Nov 2019 08:17:11 -0700 Subject: [PATCH] Fix errors related to newest nim versions --- .gitignore | 1 - src/einheit.nim | 23 +++++++---------------- src/einheit/utils.nim | 2 +- tests/test.nim | 2 +- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 7faae31..ebcd67f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ nimcache/ *.swp *.swo /tests/test - diff --git a/src/einheit.nim b/src/einheit.nim index 4b32088..8aed431 100644 --- a/src/einheit.nim +++ b/src/einheit.nim @@ -13,7 +13,7 @@ ## self.checkRaises(OSError, newException(OSError, "OS is exploding!")) ## import macros -import unicode +import unicode except split import strutils except toLower import tables import typetraits @@ -94,15 +94,6 @@ macro toString*(obj: typed): untyped = $(obj) result = getAst(toStrAst(obj)) -proc `==`*[T](ar: openarray[T], ar2: openarray[T]): bool = - ## helper proc to compare arrays - if len(ar) != len(ar2): - return false - for i in countup(0, ar.len()): - if ar[i] != ar2[i]: - return false - return true - # ----------------------- Test Suite Types ------------------------------------ type TestSuite* = ref object of RootObj @@ -140,7 +131,7 @@ method runTests*(suite: TestSuite) {.base.} = # ------------------------------------ -template returnException(name, testName, snip, vals, pos, posRel) = +template returnException(name, tName, snip, vals, pos, posRel) = ## private template for raising an exception var filename = posRel.filename @@ -157,7 +148,7 @@ template returnException(name, testName, snip, vals, pos, posRel) = exc.fileName = filename exc.lineNumber = line exc.codeSnip = snip - exc.testName = testName + exc.testName = tName exc.valTable = vals exc.checkFuncName = name raise exc @@ -174,10 +165,10 @@ template checkRaises*(self: untyped, error: untyped, try: code - var + let codeStr = astToStr(code).split().join(" ") snip = "$1, $2".format(astToStr(error), codeStr) - vals = {codeStr: "No Exception Raised"}.toTable() + vals = [(codeStr, "No Exception Raised")].toTable() testName = self.currentTestName returnException("checkRaises", testName, snip, vals, pos, posRel) @@ -186,11 +177,11 @@ template checkRaises*(self: untyped, error: untyped, except TestAssertError: raise except Exception: - var + let e = getCurrentException() codeStr = astToStr(code).split().join(" ") snip = "$1, $2".format(astToStr(error), codeStr) - vals = {codeStr: $e.name}.toTable() + vals = [(codeStr, $e.name)].toTable() testName = self.currentTestName returnException("checkRaises", testName, snip, vals, pos, posRel) diff --git a/src/einheit/utils.nim b/src/einheit/utils.nim index 1248ace..75246d4 100644 --- a/src/einheit/utils.nim +++ b/src/einheit/utils.nim @@ -47,7 +47,7 @@ elif defined(ECMAScript) and defined(nodejs): var process {.importc, nodecl.}: ref ProcessObj - + proc getTermSize*(): (int, int) = let t = process.stdout return (t.rows, t.columns) diff --git a/tests/test.nim b/tests/test.nim index 3e1247d..1701c94 100644 --- a/tests/test.nim +++ b/tests/test.nim @@ -73,7 +73,7 @@ testSuite TestInherit of UnitTestsNew: proc raisesOs() = # This proc won't be invoked as a test - raise newException(SystemError, "Oh no! OS malfunction!") + raise newException(CatchableError, "Oh no! OS malfunction!") method testRaises() =