ARC: ported the GC tests over to --gc:arc
This commit is contained in:
parent
879801c639
commit
72237e2bcf
14 changed files with 79 additions and 29 deletions
|
|
@ -3,20 +3,28 @@ discard """
|
|||
disabled: "32bit"
|
||||
"""
|
||||
|
||||
from strutils import join
|
||||
|
||||
type
|
||||
TFoo * = object
|
||||
TFoo* = object
|
||||
id: int
|
||||
fn: proc(){.closure.}
|
||||
var foo_counter = 0
|
||||
var alive_foos = newseq[int](0)
|
||||
|
||||
proc free*(some: ref TFoo) =
|
||||
#echo "Tfoo #", some.id, " freed"
|
||||
alive_foos.del alive_foos.find(some.id)
|
||||
when defined(gcDestructors):
|
||||
proc `=destroy`(some: var TFoo) =
|
||||
alive_foos.del alive_foos.find(some.id)
|
||||
`=destroy`(some.fn)
|
||||
|
||||
else:
|
||||
proc free*(some: ref TFoo) =
|
||||
#echo "Tfoo #", some.id, " freed"
|
||||
alive_foos.del alive_foos.find(some.id)
|
||||
|
||||
proc newFoo*(): ref TFoo =
|
||||
new result, free
|
||||
when defined(gcDestructors):
|
||||
new result
|
||||
else:
|
||||
new result, free
|
||||
|
||||
result.id = foo_counter
|
||||
alive_foos.add result.id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue