texpandmacro.nim 406 B

12345678910111213141516171819202122232425
  1. discard """
  2. cmd: "nim c --expandMacro:foo $file"
  3. nimout: '''texpandmacro.nim(20, 1) Hint: expanded macro:
  4. echo ["injected echo"]
  5. var x = 4
  6. type
  7. Hello = object
  8. private: string [ExpandMacro]
  9. '''
  10. output: '''injected echo'''
  11. """
  12. import macros
  13. macro foo(x: untyped): untyped =
  14. result = quote do:
  15. echo "injected echo"
  16. `x`
  17. foo:
  18. var x = 4
  19. type
  20. Hello = object
  21. private: string