diff options
Diffstat (limited to 'tests/macros/tmacro2.nim')
-rw-r--r-- | tests/macros/tmacro2.nim | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/macros/tmacro2.nim b/tests/macros/tmacro2.nim new file mode 100644 index 000000000..1ad63ec8c --- /dev/null +++ b/tests/macros/tmacro2.nim @@ -0,0 +1,36 @@ +discard """ + output: "ta-da Your value sir: 'HE!!!!o Wor!!d'" +""" + +import macros, strutils + +proc testBlock(): string {.compileTime.} = + block myBlock: + while true: + echo "inner block" + break myBlock + echo "outer block" + result = "ta-da" + +macro mac(n: typed): string = + let n = callsite() + expectKind(n, nnkCall) + expectLen(n, 2) + expectKind(n[1], nnkStrLit) + var s: string = n[1].strVal + s = s.replace("l", "!!") + result = newStrLitNode("Your value sir: '$#'" % [s]) + +const s = testBlock() +const t = mac("HEllo World") +echo s, " ", t + + +#----------------------------------------------------------------------------- +# issue #15326 +macro m(n:typed):auto = + result = n + +proc f[T](x:T): T {.m.} = x + +discard f(3) \ No newline at end of file |