fixes system.doAssertRaises
This commit is contained in:
parent
9bc963508f
commit
4a9f6f00ad
1 changed files with 5 additions and 4 deletions
|
|
@ -4136,17 +4136,18 @@ template doAssertRaises*(exception, code: untyped): typed =
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
doAssertRaises(ValueError):
|
doAssertRaises(ValueError):
|
||||||
raise newException(ValueError, "Hello World")
|
raise newException(ValueError, "Hello World")
|
||||||
|
var wrong = false
|
||||||
try:
|
try:
|
||||||
block:
|
code
|
||||||
code
|
wrong = true
|
||||||
raiseAssert(astToStr(exception) & " wasn't raised by:\n" & astToStr(code))
|
|
||||||
except exception:
|
except exception:
|
||||||
discard
|
discard
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
raiseAssert(astToStr(exception) &
|
raiseAssert(astToStr(exception) &
|
||||||
" wasn't raised, another error was raised instead by:\n"&
|
" wasn't raised, another error was raised instead by:\n"&
|
||||||
astToStr(code))
|
astToStr(code))
|
||||||
|
if wrong:
|
||||||
|
raiseAssert(astToStr(exception) & " wasn't raised by:\n" & astToStr(code))
|
||||||
|
|
||||||
when defined(cpp) and appType != "lib" and not defined(js) and
|
when defined(cpp) and appType != "lib" and not defined(js) and
|
||||||
not defined(nimscript) and hostOS != "standalone":
|
not defined(nimscript) and hostOS != "standalone":
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue