tcgbug.nim 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. discard """
  2. output: '''
  3. success
  4. M1 M2
  5. '''
  6. """
  7. type
  8. TObj = object
  9. x, y: int
  10. PObj = ref TObj
  11. proc p(a: PObj) =
  12. a.x = 0
  13. proc q(a: var PObj) =
  14. a.p()
  15. var
  16. a: PObj
  17. new(a)
  18. q(a)
  19. # bug #914
  20. when defined(windows):
  21. var x = newWideCString("Hello")
  22. echo "success"
  23. # bug #833
  24. type
  25. PFuture*[T] = ref object
  26. value*: T
  27. finished*: bool
  28. cb: proc (future: PFuture[T]) {.closure.}
  29. var k = PFuture[void]()
  30. ##bug #9297
  31. import strutils
  32. type
  33. MyKind = enum
  34. M1, M2, M3
  35. MyObject {.exportc: "ExtObject"} = object
  36. case kind: MyKind
  37. of M1: a:int
  38. of M2: b:float
  39. of M3: c:cstring
  40. MyObjectRef {.exportc: "ExtObject2"} = ref object
  41. case kind: MyKind
  42. of M1: a:int
  43. of M2: b:float
  44. of M3: c:cstring
  45. proc newMyObject(kind: MyKind, val: string): MyObject =
  46. result.kind = kind
  47. case kind
  48. of M1: result.a = parseInt(val)
  49. of M2: result.b = parseFloat(val)
  50. of M3: result.c = val
  51. proc newMyObjectRef(kind: MyKind, val: string): MyObjectRef =
  52. new(result)
  53. result.kind = kind
  54. case kind
  55. of M1: result.a = parseInt(val)
  56. of M2: result.b = parseFloat(val)
  57. of M3: result.c = val
  58. echo newMyObject(M1, "2").kind, " ", newMyObjectRef(M2, "3").kind