tastrepr.nim 933 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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
  11. a = 1
  12. b = 2
  13. type
  14. A* = object
  15. var data = @[(1, "one"), (2, "two")]
  16. for (i, d) in pairs(data):
  17. discard
  18. for i, d in pairs(data):
  19. discard
  20. for i, (x, y) in pairs(data):
  21. discard
  22. var (a, b) = (1, 2)
  23. type
  24. A* = object
  25. '''
  26. """
  27. import macros
  28. macro echoTypedRepr(arg: typed) =
  29. result = newCall(ident"echo", newLit(arg.repr))
  30. macro echoUntypedRepr(arg: untyped) =
  31. result = newCall(ident"echo", newLit(arg.repr))
  32. template echoTypedAndUntypedRepr(arg: untyped) =
  33. echoTypedRepr(arg)
  34. echoUntypedRepr(arg)
  35. echoTypedAndUntypedRepr:
  36. var data = @[(1,"one"), (2,"two")]
  37. for (i, d) in pairs(data):
  38. discard
  39. for i, d in pairs(data):
  40. discard
  41. for i, (x,y) in pairs(data):
  42. discard
  43. var (a,b) = (1,2)
  44. type A* = object # issue #22933