From d9d82fb0af8688e7c847bb7b0c3b2e38f7c8a735 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 3 Oct 2012 21:11:41 +0300 Subject: syntax compatibility between do blocks and stmt blocks See the section `do notation` in the manual for more info. * nkMacroStmt has been removed Macro statements are now mapped to regular nkCall nodes. The support for additional clauses (such as else, except, of, etc) have been restored - they will now appear as additional arguments for the nkCall node (as nkElse, nkExcept, etc nodes) * fixed some regressions in the `is` operator and semCompiles --- lib/pure/unittest.nim | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/pure/unittest.nim') diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index 0233b8bac..fce84bea4 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -151,7 +151,7 @@ template require*(conditions: stmt): stmt {.immediate, dirty.} = const AbortOnError {.inject.} = true check conditions -macro expect*(exp: stmt): stmt {.immediate.} = +macro expect*(exceptions: varargs[expr], body: stmt): stmt {.immediate.} = let exp = callsite() template expectBody(errorTypes, lineInfoLit: expr, body: stmt): PNimrodNode {.dirty.} = @@ -162,12 +162,11 @@ macro expect*(exp: stmt): stmt {.immediate.} = except errorTypes: nil - var expectCall = exp[0] - var body = exp[1] - + var body = exp[exp.len - 1] + var errorTypes = newNimNode(nnkBracket) - for i in countup(1, expectCall.len - 1): - errorTypes.add(expectCall[i]) + for i in countup(1, exp.len - 2): + errorTypes.add(exp[i]) result = getAst(expectBody(errorTypes, exp.lineinfo, body)) -- cgit 1.4.1-2-gfad0