Fix errors related to newest nim versions
This commit is contained in:
parent
bc49edfd43
commit
84378f3ddd
4 changed files with 9 additions and 19 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,4 +2,3 @@ nimcache/
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
/tests/test
|
/tests/test
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
## self.checkRaises(OSError, newException(OSError, "OS is exploding!"))
|
## self.checkRaises(OSError, newException(OSError, "OS is exploding!"))
|
||||||
##
|
##
|
||||||
import macros
|
import macros
|
||||||
import unicode
|
import unicode except split
|
||||||
import strutils except toLower
|
import strutils except toLower
|
||||||
import tables
|
import tables
|
||||||
import typetraits
|
import typetraits
|
||||||
|
|
@ -94,15 +94,6 @@ macro toString*(obj: typed): untyped =
|
||||||
$(obj)
|
$(obj)
|
||||||
result = getAst(toStrAst(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 ------------------------------------
|
# ----------------------- Test Suite Types ------------------------------------
|
||||||
type
|
type
|
||||||
TestSuite* = ref object of RootObj
|
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
|
## private template for raising an exception
|
||||||
var
|
var
|
||||||
filename = posRel.filename
|
filename = posRel.filename
|
||||||
|
|
@ -157,7 +148,7 @@ template returnException(name, testName, snip, vals, pos, posRel) =
|
||||||
exc.fileName = filename
|
exc.fileName = filename
|
||||||
exc.lineNumber = line
|
exc.lineNumber = line
|
||||||
exc.codeSnip = snip
|
exc.codeSnip = snip
|
||||||
exc.testName = testName
|
exc.testName = tName
|
||||||
exc.valTable = vals
|
exc.valTable = vals
|
||||||
exc.checkFuncName = name
|
exc.checkFuncName = name
|
||||||
raise exc
|
raise exc
|
||||||
|
|
@ -174,10 +165,10 @@ template checkRaises*(self: untyped, error: untyped,
|
||||||
|
|
||||||
try:
|
try:
|
||||||
code
|
code
|
||||||
var
|
let
|
||||||
codeStr = astToStr(code).split().join(" ")
|
codeStr = astToStr(code).split().join(" ")
|
||||||
snip = "$1, $2".format(astToStr(error), codeStr)
|
snip = "$1, $2".format(astToStr(error), codeStr)
|
||||||
vals = {codeStr: "No Exception Raised"}.toTable()
|
vals = [(codeStr, "No Exception Raised")].toTable()
|
||||||
testName = self.currentTestName
|
testName = self.currentTestName
|
||||||
returnException("checkRaises", testName, snip, vals, pos, posRel)
|
returnException("checkRaises", testName, snip, vals, pos, posRel)
|
||||||
|
|
||||||
|
|
@ -186,11 +177,11 @@ template checkRaises*(self: untyped, error: untyped,
|
||||||
except TestAssertError:
|
except TestAssertError:
|
||||||
raise
|
raise
|
||||||
except Exception:
|
except Exception:
|
||||||
var
|
let
|
||||||
e = getCurrentException()
|
e = getCurrentException()
|
||||||
codeStr = astToStr(code).split().join(" ")
|
codeStr = astToStr(code).split().join(" ")
|
||||||
snip = "$1, $2".format(astToStr(error), codeStr)
|
snip = "$1, $2".format(astToStr(error), codeStr)
|
||||||
vals = {codeStr: $e.name}.toTable()
|
vals = [(codeStr, $e.name)].toTable()
|
||||||
testName = self.currentTestName
|
testName = self.currentTestName
|
||||||
|
|
||||||
returnException("checkRaises", testName, snip, vals, pos, posRel)
|
returnException("checkRaises", testName, snip, vals, pos, posRel)
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ testSuite TestInherit of UnitTestsNew:
|
||||||
|
|
||||||
proc raisesOs() =
|
proc raisesOs() =
|
||||||
# This proc won't be invoked as a test
|
# 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() =
|
method testRaises() =
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue