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
This commit is contained in:
parent
a6d5707faf
commit
d9d82fb0af
21 changed files with 142 additions and 168 deletions
|
|
@ -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))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue