version(assert) and Phobos release unittest build

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Thu Nov 28 08:53:47 PST 2013


On 28/11/13 17:40, Dicebot wrote:
> I have quickly tested it and looks like asserts are not removed from unittest
> blocks in release builds, only from normal code. Which does not seem to be
> documented on dlang.org but was probably introduced exactly to prevent existing
> tests from breaking in release mode. I have just learned something new :)

Both version(assert) and version(release) are ignored inside unittest blocks. 
Consider the attached code: running with rdmd -unittest -release results in output:

     I don't respect release mode inside unittest blocks
     Release mode is disabled.

Which is interesting but irritating to say the least, because it means things 
like testing contracts are more difficult to unittest effectively.

OK, OK, I could do

     version(assert)
     {
         unittest { ... }
     }

... but that makes for an annoying separation out of unittests.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: versionrelease.d
Type: text/x-dsrc
Size: 321 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20131128/ca40fbb3/attachment-0001.d>


More information about the Digitalmars-d-learn mailing list