t13062.nim 640 B

12345678910111213141516171819202122232425262728293031323334
  1. discard """
  2. matrix: "--mm:refc; --mm:orc"
  3. targets: "c cpp"
  4. """
  5. import atomics
  6. type
  7. Pledge* {.exportc.} = object
  8. p: PledgePtr
  9. PledgeKind {.exportc.} = enum
  10. Single
  11. Iteration
  12. PledgePtr {.exportc.} = ptr object
  13. case kind: PledgeKind
  14. of Single:
  15. impl: PledgeImpl
  16. of Iteration:
  17. discard
  18. PledgeImpl {.exportc.} = object
  19. fulfilled: Atomic[bool]
  20. var x: Pledge
  21. when defined(cpp):
  22. # TODO: fixme
  23. discard "it doesn't work for refc/orc because of contrived `Atomic` in cpp"
  24. elif defined(gcRefc):
  25. doAssert x.repr == "[p = nil]"
  26. else: # fixme # bug #20081
  27. doAssert x.repr == "Pledge(p: nil)"