-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macros: add
stamp
for unquoting a template body
- Loading branch information
Showing
2 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
discard """ | ||
description: Tests for macros.stamp | ||
""" | ||
|
||
import std/macros | ||
|
||
block binder: | ||
## Test automatic binding behavior | ||
macro simple() = | ||
let ast = stamp(echo "hello") | ||
doAssert ast[0] == bindSym"echo" | ||
|
||
simple() | ||
|
||
macro noResult() = | ||
let ast = stamp(result) | ||
doAssert ast.kind == nnkIdent | ||
doAssert eqIdent(ast, "result") | ||
|
||
noResult() |