Skip to content

Commit

Permalink
Add unit test to make sure logging works from within finalizers.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Sep 13, 2015
1 parent 0ef97a5 commit 7a5e536
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/vibe/core/log.d
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,19 @@ private version (Windows) {
enum STD_ERROR_HANDLE = cast(DWORD)-12;
extern(System) HANDLE GetStdHandle(DWORD nStdHandle);
}

unittest { // make sure the default logger doesn't allocate/is usable within finalizers
bool destroyed = false;

class Test {
~this()
{
logInfo("logInfo doesn't allocate.");
destroyed = true;
}
}

auto t = new Test;
destroy(t);
assert(destroyed);
}

0 comments on commit 7a5e536

Please sign in to comment.