For templated code it is often useful to verify that for function attributes (e.g. @nogc
are inferred correctly. To ensure this for a specific test and thus type the entire unittest can be annotated
@safe @nogc pure nothrow unittest
{
import std.math;
assert(exp(0) == 1);
assert(log(1) == 0);
}
Note that of course in D every block can be annotated with attributes and the compilers, of course, verifies that they are correct. So for example the following would be similar to the example above:
unittest
{
import std.math;
@safe {
assert(exp(0) == 1);
assert(log(1) == 0);
}
}