Please consider:
size_t foo() {
static size_t var1 = 1;
var1 = var1 + 1;
return var1;
}
unittest {
assert(foo() == 2);
assert(foo() == 3);
}
which works as expected.
But
size_t foo1() {
static size_t var1 = 1;
var1 = var1 + 1;
return var1;
}
unittest {
assert(foo1() == 2);
}
unittest {
assert(foo1() == 2);
}
Fails on the second unittest.
I appreciate this behaviour matches the docs (so not a bug), but is it desirable?
To me, as a test harness, a umittest block should be a completely fresh-from-scratch invocation of the code inside the block, and thus not depend on the result/effects of any previous unittest.