trepr2.nim 533 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. discard """
  2. outputsub: ""
  3. """
  4. # output not testable because repr prints pointer adresses
  5. # test the new "repr" built-in proc
  6. type
  7. TEnum = enum
  8. en1, en2, en3, en4, en5, en6
  9. TPoint {.final.} = object
  10. x, y, z: int
  11. s: array[0..1, string]
  12. e: TEnum
  13. var
  14. p: TPoint
  15. q: ref TPoint
  16. s: seq[ref TPoint]
  17. p.x = 0
  18. p.y = 13
  19. p.z = 45
  20. p.s[0] = "abc"
  21. p.s[1] = "xyz"
  22. p.e = en6
  23. new(q)
  24. q[] = p
  25. s = @[q, q, q, q]
  26. writeLine(stdout, repr(p))
  27. writeLine(stdout, repr(q))
  28. writeLine(stdout, repr(s))
  29. writeLine(stdout, repr(en4))