diff options
Diffstat (limited to 'tests/whenstmt/twhen_macro.nim')
-rw-r--r-- | tests/whenstmt/twhen_macro.nim | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/whenstmt/twhen_macro.nim b/tests/whenstmt/twhen_macro.nim new file mode 100644 index 000000000..b5168144e --- /dev/null +++ b/tests/whenstmt/twhen_macro.nim @@ -0,0 +1,24 @@ +import macros + +discard """ + output: ''' +when - test +''' +""" + +# test that when stmt works from within a macro + +macro output(s: string, xs: varargs[untyped]): auto = + result = quote do: + when compiles(`s`): + "when - " & `s` + elif compiles(`s`): + "elif - " & `s` + # should never get here so this should not break + broken.xs + else: + "else - " & `s` + # should never get here so this should not break + more.broken.xs + +echo output("test") \ No newline at end of file |