t9578.nim 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. discard """
  2. output: '''
  3. @[(v: -1), (v: 2), (v: 3)]
  4. @[(v: -1), (v: 2), (v: 3)]
  5. [(v: -1), (v: 2), (v: 3)]
  6. [(v: -1), (v: 2), (v: 3)]
  7. ((v: -1), (v: 2), (v: 3))
  8. ((v: -1), (v: 2), (v: 3))
  9. @[(v: -1), (v: 2), (v: 3)]
  10. @[(v: -1), (v: 2), (v: 3)]
  11. @[(v: -1), (v: 2), (v: 3)]
  12. '''
  13. """
  14. type mytype* = object
  15. v:int
  16. proc f*(x:ptr mytype) = x.v = -1
  17. func g(x:int):mytype = mytype(v:x)
  18. import xseq9578
  19. block:
  20. var x = @[1.g,2.g,3.g]
  21. testSeq(x)
  22. echo x
  23. block:
  24. var x = @[1.g,2.g,3.g]
  25. var y = addr x
  26. testSeq2(y)
  27. echo x
  28. import xarray9578
  29. block:
  30. var x = [1.g,2.g,3.g]
  31. testArray(x)
  32. echo x
  33. block:
  34. var x = [1.g,2.g,3.g]
  35. var y = addr x
  36. testArray2(y)
  37. echo x
  38. import xtuple9578
  39. block:
  40. var x = (1.g,2.g,3.g)
  41. testTuple(x)
  42. echo x
  43. block:
  44. var x = (1.g,2.g,3.g)
  45. var y = addr x
  46. testTuple2(y)
  47. echo x
  48. import xoa9578
  49. block:
  50. var x = @[1.g,2.g,3.g]
  51. testOpenArray(x)
  52. echo x
  53. import xua9578
  54. block:
  55. var x = @[1.g,2.g,3.g]
  56. var y = cast[ptr UncheckedArray[mytype]](addr x[0])
  57. testUncheckedArray(y[])
  58. echo x
  59. block:
  60. var x = @[1.g,2.g,3.g]
  61. var y = cast[ptr UncheckedArray[mytype]](addr x[0])
  62. testUncheckedArray2(y)
  63. echo x