diff options
Diffstat (limited to 'tests/arc/tarcmisc.nim')
-rw-r--r-- | tests/arc/tarcmisc.nim | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim index aef230334..88582303d 100644 --- a/tests/arc/tarcmisc.nim +++ b/tests/arc/tarcmisc.nim @@ -1,5 +1,6 @@ discard """ output: ''' +Destructor for TestTestObj =destroy called 123xyzabc destroyed: false @@ -36,9 +37,33 @@ destroying variable: 20 destroying variable: 10 closed ''' - cmd: "nim c --gc:arc --deepcopy:on -d:nimAllocPagesViaMalloc $file" + cmd: "nim c --mm:arc --deepcopy:on -d:nimAllocPagesViaMalloc $file" """ +block: # bug #23627 + type + TestObj = object of RootObj + + Test2 = object of RootObj + foo: TestObj + + TestTestObj = object of RootObj + shit: TestObj + + proc `=destroy`(x: TestTestObj) = + echo "Destructor for TestTestObj" + let test = Test2(foo: TestObj()) + + proc testCaseT() = + let tt1 {.used.} = TestTestObj(shit: TestObj()) + + + proc main() = + testCaseT() + + main() + + # bug #9401 type @@ -46,13 +71,12 @@ type len: int data: ptr UncheckedArray[float] -proc `=destroy`*(m: var MyObj) = +proc `=destroy`*(m: MyObj) = echo "=destroy called" if m.data != nil: deallocShared(m.data) - m.data = nil type MyObjDistinct = distinct MyObj @@ -104,7 +128,7 @@ bbb("123") type Variable = ref object value: int -proc `=destroy`(self: var typeof(Variable()[])) = +proc `=destroy`(self: typeof(Variable()[])) = echo "destroying variable: ",self.value proc newVariable(value: int): Variable = @@ -158,7 +182,7 @@ type B = ref object of A x: int -proc `=destroy`(x: var AObj) = +proc `=destroy`(x: AObj) = close(x.io) echo "closed" |