From 4a9f6f00adb3234e604faa40cca52bc15ede9769 Mon Sep 17 00:00:00 2001 From: Araq Date: Wed, 18 Apr 2018 21:30:28 +0200 Subject: [PATCH] fixes system.doAssertRaises --- lib/system.nim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 9f0b115973..5e08dadc0b 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":