Files
Nim/tests/whenstmt/twhen_macro.nim
ringabout 3dbf2ac946 remove echo statements in tests (part 1) (#20178)
* remove echo statements

* Update tests/vm/triangle_array.nim

* Update tests/vm/tyaytypedesc.nim

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
2022-08-23 19:28:51 +02:00

18 lines
451 B
Nim

import macros
# 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
doAssert output("test") == "when - test"