version(assert) and Phobos release unittest build
Joseph Rushton Wakeling
joseph.wakeling at webdrake.net
Thu Nov 28 08:18:27 PST 2013
On 28/11/13 17:04, Dicebot wrote:
> Oh, oops, I thought your issue is exactly other way around, sorry. That looks
> like an issue in assertThrown implementation. probably worth a bugzilla entry.
It's a bit mysterious. Consider this minimal example:
unittest
{
import std.exception, core.exception;
assertThrown!AssertError(assert(false));
}
... which should be fine in non-release mode and (potentially) problematic in
release mode. In fact it makes no difference whether you call:
rdmd -main -unittest -cov assert.d
or
rdmd -main -unittest -cov -release assert.d
... either works without complaint, which is not what you'd expect: you'd expect
assertThrown to report an error in the case of -release mode.
Now, replace the assert(false) in the above with assert(true). This time, in
both cases, you get:
core.exception.AssertError at assert.d(4): assertThrown failed: No AssertError
was thrown.
... which is kind of in line with expectations, I suppose.
Now, wrap the line in question in version(assert) { ... } -- still fails in both
cases.
Now wrap it in version(release) {} else { ... } -- again, still fails with both
build/run options.
It's this last one which is really mysterious to me, because it suggests that
neither version(assert) nor version(release) is being respected properly.
More information about the Digitalmars-d-learn
mailing list