texpectIdent2.nim 413 B

12345678910111213141516171819202122232425
  1. discard """
  2. errormsg: "Expected identifier to be `foo` here"
  3. line: 24
  4. """
  5. import macros
  6. macro testTyped(arg: typed): void =
  7. arg.expectKind nnkStmtList
  8. arg.expectLen 2
  9. arg[0].expectKind nnkCall
  10. arg[0][0].expectIdent "foo" # must pass
  11. arg[1].expectKind nnkCall
  12. arg[1][0].expectIdent "foo" # must fail
  13. proc foo(arg: int) =
  14. discard
  15. proc bar(arg: int) =
  16. discard
  17. testTyped:
  18. foo(123)
  19. bar(321)