On Wednesday, February 27, 2013 21:21:04 H. S. Teoh wrote: > On Wed, Feb 27, 2013 at 08:57:57PM -0800, Jonathan M Davis wrote: > > On Wednesday, February 27, 2013 20:50:02 H. S. Teoh wrote: > > > I just had a sinking realization today: I have been using assert inside > > > unittests to check for test results, but actually, this is wrong! > > > > > > Why? Because when you compile with -release -unittest, all those asserts > > > disappear, and the unittests become useless. The correct way is to use > > > enforce instead of assert. > > > > > > Unfortunately, Phobos unittests are full of asserts rather than enforce. > > > > Actually, building with -release doesn't disable assertions if you build > > with -unittest. This code will assert if you bulid with both -release and > > - > > unittest: > [...] > > Hmm. I was using assertNotThrown... which disappears with -release. I > was under the impression that it was implemented using assert, but I > guess I was wrong.
No, it's explicitly throwing an AssertError. I wouldn't expect that to go away regardless of the compiler flags being used. Much as AssertError is used by assertions, it's defined quite normally in druntime, and I don't know how it could be affected by compiler flags. If assertThrown or assertNotThrown is going away in -release, something very weird is going on. - Jonathan M Daves
