diff options
Diffstat (limited to 'tests/arc/tarc_orc.nim')
-rw-r--r-- | tests/arc/tarc_orc.nim | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/tests/arc/tarc_orc.nim b/tests/arc/tarc_orc.nim index 594950d71..f2c7de2fc 100644 --- a/tests/arc/tarc_orc.nim +++ b/tests/arc/tarc_orc.nim @@ -136,4 +136,51 @@ proc main2 = doAssert a.len == 2 doAssert b.len == 0 -main2() \ No newline at end of file +main2() + +block: + type + TestObj = object of RootObj + name: string + + TestSubObj = object of TestObj + objname: string + + proc `=destroy`(x: TestObj) = + `=destroy`(x.name) + + proc `=destroy`(x: TestSubObj) = + `=destroy`(x.objname) + `=destroy`(TestObj(x)) + + proc testCase() = + let t1 {.used.} = TestSubObj(objname: "tso1", name: "to1") + + proc main() = + testCase() + + main() + +block: # bug #23858 + type Object = object + a: int + b: ref int + var x = 0 + proc fn(): auto {.cdecl.} = + inc x + return Object() + discard fn() + doAssert x == 1 + +block: # bug #24147 + type + O = object of RootObj + val: string + OO = object of O + + proc `=copy`(dest: var O, src: O) = + dest.val = src.val + + let oo = OO(val: "hello world") + var ooCopy : OO + `=copy`(ooCopy, oo) |