new compiler feature: --expandMacro
This commit is contained in:
parent
dc5fa90b43
commit
9ecb1aae80
7 changed files with 34 additions and 4 deletions
18
tests/compilerfeatures/texpandmacro.nim
Normal file
18
tests/compilerfeatures/texpandmacro.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
discard """
|
||||
cmd: "nim c --expandMacro:foo $file"
|
||||
nimout: '''Hint: expanded macro:
|
||||
echo ["injected echo"]
|
||||
var x = 4 [ExpandMacro]
|
||||
'''
|
||||
output: '''injected echo'''
|
||||
"""
|
||||
|
||||
import macros
|
||||
|
||||
macro foo(x: untyped): untyped =
|
||||
result = quote do:
|
||||
echo "injected echo"
|
||||
`x`
|
||||
|
||||
foo:
|
||||
var x = 4
|
||||
Loading…
Add table
Add a link
Reference in a new issue