From eb360bda387063d970669bf2683dca484a673cea Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 16 Apr 2017 20:52:24 +0200 Subject: [PATCH] Add unittest to check RefCounted calles struct destructors --- source/tanya/memory/types.d | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/source/tanya/memory/types.d b/source/tanya/memory/types.d index af0f1ac..4efb1ca 100644 --- a/source/tanya/memory/types.d +++ b/source/tanya/memory/types.d @@ -495,3 +495,20 @@ private @nogc unittest auto rc = defaultAllocator.refCounted!(int[])(5); assert(rc.length == 5); } + +private @nogc unittest +{ + static bool destroyed = false; + + struct F + { + ~this() @nogc + { + destroyed = true; + } + } + { + auto rc = defaultAllocator.refCounted!F(); + } + assert(destroyed); +}