diff options
author | Araq <rumpf_a@web.de> | 2011-03-08 01:59:15 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-03-08 01:59:15 +0100 |
commit | fa332b729835f70c71ee235626490697779fee87 (patch) | |
tree | e6e7039e25fdd73f22bde845e1b02e8b0ded2a5a /tests/accept/run/tmacro2.nim | |
parent | f9c6cec90c1a67e885b6172a8bccfb014175f60b (diff) | |
download | Nim-fa332b729835f70c71ee235626490697779fee87.tar.gz |
fixes #13; fixes #18
Diffstat (limited to 'tests/accept/run/tmacro2.nim')
-rw-r--r-- | tests/accept/run/tmacro2.nim | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/accept/run/tmacro2.nim b/tests/accept/run/tmacro2.nim new file mode 100644 index 000000000..6aa9bb57d --- /dev/null +++ b/tests/accept/run/tmacro2.nim @@ -0,0 +1,27 @@ +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: expr): expr = + 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 + + |