Open PetarKirov opened 8 years ago
One possible way to do this may be to pre-allocate an array of records for each unittest. Inside the assert* functions the code will then fill the corresponding record for the current unittest. After the test runner finishes it will iterate through the elements of the array and perform string formating as needed.
A different strategy is to use ref-counted objects, but that seems even more involved for the scope of this project, considering that currently phobos provides little support for this style of memory management.
A third option is to use fibers or ranges to separate the code that needs to allocate memory from code that just checks the assert* functions parameters.
To clarify about my idea to use fibers - instead of throwing DUnitAssertError, you can fiber.yield() directly to the code that is supposed to catch the exception
I'm writing a library which needs to have
@safe @nogc pure nothrow
API. To ensure this, I annotate my unittests with those attributes, however this currently means that I can't usedunit.toolkit
in those unittests.