mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-24 00:05:25 +00:00
new compiler feature: --expandMacro
This commit is contained in:
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
|
||||
Reference in New Issue
Block a user