diff --git a/tests/datastore/testsharedptr.nim b/tests/datastore/testsharedptr.nim index e27c00d..c98cac3 100644 --- a/tests/datastore/testsharedptr.nim +++ b/tests/datastore/testsharedptr.nim @@ -10,13 +10,21 @@ include pkg/datastore/threads/sharedptr include pkg/datastore/threads/databuffer -type TestObj = object - val: ref int +type + TestObj = object + val: ref int + + TestObjGen[T] = object + val: ref T proc `=destroy`(obj: var TestObj) = echo "test obj destroy" obj.val[] = 0 +proc `=destroy`[T: int](obj: var TestObjGen[T]) = + echo "test obj destroy" + obj.val[] = 0 + proc destroyTest(intref: ref int) = let a: SharedPtr[TestObj] = newSharedPtr(unsafeIsolate TestObj(val: intref)) echo "a[]: ", a[] @@ -77,3 +85,15 @@ suite "Share buffer test": finally: a.release() check intref[] == 0 + + test "test destroy release generic no proc": + echo "\nintref setup:\n" + let intref: ref int = new(ref int) + intref[] = 30 + var b: SharedPtr[TestObjGen[int]] = newSharedPtr(unsafeIsolate TestObjGen[int](val: intref)) + try: + echo "a[]: ", b[] + check b[].val[] == 30 + finally: + b.release() + check intref[] == 0 \ No newline at end of file