summary refs log tree commit diff stats
path: root/lib/system.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2018-04-18 21:30:28 +0200
committerAraq <rumpf_a@web.de>2018-04-18 21:30:38 +0200
commit4a9f6f00adb3234e604faa40cca52bc15ede9769 (patch)
tree70a9c6d67d3d899f403e62c06ba47bf39721ec2d /lib/system.nim
parent9bc963508f29de8dd785a02b01f3159530a0ee2e (diff)
downloadNim-4a9f6f00adb3234e604faa40cca52bc15ede9769.tar.gz
fixes system.doAssertRaises
Diffstat (limited to 'lib/system.nim')
-rw-r--r--lib/system.nim9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 9f0b11597..5e08dadc0 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -4136,17 +4136,18 @@ template doAssertRaises*(exception, code: untyped): typed =
   runnableExamples:
     doAssertRaises(ValueError):
       raise newException(ValueError, "Hello World")
-
+  var wrong = false
   try:
-    block:
-      code
-    raiseAssert(astToStr(exception) & " wasn't raised by:\n" & astToStr(code))
+    code
+    wrong = true
   except exception:
     discard
   except Exception as exc:
     raiseAssert(astToStr(exception) &
                 " wasn't raised, another error was raised instead by:\n"&
                 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
     not defined(nimscript) and hostOS != "standalone":