Fix errors related to newest nim versions

This commit is contained in:
Joey Yakimowich-Payne 2019-11-05 08:17:11 -07:00
commit 84378f3ddd
4 changed files with 9 additions and 19 deletions

1
.gitignore vendored
View file

@ -2,4 +2,3 @@ nimcache/
*.swp
*.swo
/tests/test

View file

@ -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)

View file

@ -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)

View file

@ -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() =