tastrepr.nim 861 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. discard """
  2. output: '''
  3. var data = @[(1, "one"), (2, "two")]
  4. for (i, d) in pairs(data):
  5. discard
  6. for i, d in pairs(data):
  7. discard
  8. for i, (x, y) in pairs(data):
  9. discard
  10. var (a, b) = (1, 2)
  11. var data = @[(1, "one"), (2, "two")]
  12. for (i, d) in pairs(data):
  13. discard
  14. for i, d in pairs(data):
  15. discard
  16. for i, (x, y) in pairs(data):
  17. discard
  18. var (a, b) = (1, 2)
  19. '''
  20. """
  21. import macros
  22. macro echoTypedRepr(arg: typed) =
  23. result = newCall(ident"echo", newLit(arg.repr))
  24. macro echoUntypedRepr(arg: untyped) =
  25. result = newCall(ident"echo", newLit(arg.repr))
  26. template echoTypedAndUntypedRepr(arg: untyped) =
  27. echoTypedRepr(arg)
  28. echoUntypedRepr(arg)
  29. echoTypedAndUntypedRepr:
  30. var data = @[(1,"one"), (2,"two")]
  31. for (i, d) in pairs(data):
  32. discard
  33. for i, d in pairs(data):
  34. discard
  35. for i, (x,y) in pairs(data):
  36. discard
  37. var (a,b) = (1,2)