* fixes #19401; fixes #19402; rework Forward declaration and finalizer for ORC * add more tests * give it a name * make more tests * fixes tests * hidden addr for cpp * move code to a function
This commit is contained in:
parent
3d2f0e2c7c
commit
80e739f2bf
3 changed files with 112 additions and 24 deletions
32
tests/arc/t19401.nim
Normal file
32
tests/arc/t19401.nim
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
discard """
|
||||
output: '''
|
||||
delete foo
|
||||
delete foo
|
||||
delete foo
|
||||
'''
|
||||
matrix: "--mm:arc"
|
||||
"""
|
||||
|
||||
type Foo = ref object
|
||||
data: int
|
||||
proc delete(self: Foo)
|
||||
proc newFoo: Foo =
|
||||
let x = 12
|
||||
discard x
|
||||
new(result, delete)
|
||||
result.data = x
|
||||
proc delete(self: Foo) =
|
||||
doAssert self.data == 12
|
||||
echo("delete foo")
|
||||
|
||||
if isMainModule:
|
||||
proc test() =
|
||||
let x1 = newFoo()
|
||||
let x2 = newFoo()
|
||||
discard x1
|
||||
discard x2
|
||||
var x3: Foo
|
||||
new(x3, delete)
|
||||
x3.data = 12
|
||||
discard x3
|
||||
test()
|
||||
32
tests/arc/t19402.nim
Normal file
32
tests/arc/t19402.nim
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
discard """
|
||||
output: '''
|
||||
delete foo
|
||||
delete foo
|
||||
delete foo
|
||||
'''
|
||||
matrix: "--mm:arc"
|
||||
"""
|
||||
|
||||
type Foo = ref object of RootObj
|
||||
data: int
|
||||
proc delete(self: Foo)
|
||||
proc newFoo: Foo =
|
||||
let x = 12
|
||||
discard x
|
||||
new(result, delete)
|
||||
result.data = x
|
||||
proc delete(self: Foo) =
|
||||
doAssert self.data == 12
|
||||
echo("delete foo")
|
||||
|
||||
if isMainModule:
|
||||
proc test() =
|
||||
let x1 = newFoo()
|
||||
let x2 = newFoo()
|
||||
discard x1
|
||||
discard x2
|
||||
var x3: Foo
|
||||
new(x3, delete)
|
||||
x3.data = 12
|
||||
discard x3
|
||||
test()
|
||||
Loading…
Add table
Add a link
Reference in a new issue