www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - More elaborate asserts in unittests?

reply IGotD- <nise nise.com> writes:
When an assert fails in a unittest, I only get which line that 
failed. However, it would be very useful to see what the values 
are on either side of the unary boolean expression. Is this 
possible?
Oct 21 2020
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Wednesday, 21 October 2020 at 22:30:11 UTC, IGotD- wrote:
 When an assert fails in a unittest, I only get which line that 
 failed. However, it would be very useful to see what the values 
 are on either side of the unary boolean expression. Is this 
 possible?
try compiling with dmd -checkaction=context
Oct 21 2020
parent reply IGotD- <nise nise.com> writes:
On Wednesday, 21 October 2020 at 22:41:42 UTC, Adam D. Ruppe 
wrote:
 try compiling with dmd -checkaction=context
Thanks, that was simple and it worked. Speaking of this, shouldn't this be documented here for example. https://dlang.org/spec/unittest.html Just adding a friendly tip that -checkaction=context gives the user more information. I couldn't find this information anywhere.
Oct 21 2020
next sibling parent reply bachmeier <no spam.net> writes:
On Wednesday, 21 October 2020 at 22:48:04 UTC, IGotD- wrote:
 On Wednesday, 21 October 2020 at 22:41:42 UTC, Adam D. Ruppe 
 wrote:
 try compiling with dmd -checkaction=context
Thanks, that was simple and it worked. Speaking of this, shouldn't this be documented here for example. https://dlang.org/spec/unittest.html Just adding a friendly tip that -checkaction=context gives the user more information. I couldn't find this information anywhere.
Click the "Improve this page" link in the upper right corner and add what you think needs to be there. Those PRs usually get a fast response.
Oct 21 2020
parent IGotD- <nise nise.com> writes:
On Wednesday, 21 October 2020 at 23:54:41 UTC, bachmeier wrote:
 Click the "Improve this page" link in the upper right corner 
 and add what you think needs to be there. Those PRs usually get 
 a fast response.
Will do, thank you for the direction.
Oct 21 2020
prev sibling parent reply Mathias LANG <geod24 gmail.com> writes:
On Wednesday, 21 October 2020 at 22:48:04 UTC, IGotD- wrote:
 On Wednesday, 21 October 2020 at 22:41:42 UTC, Adam D. Ruppe 
 wrote:
 try compiling with dmd -checkaction=context
Thanks, that was simple and it worked. Speaking of this, shouldn't this be documented here for example. https://dlang.org/spec/unittest.html Just adding a friendly tip that -checkaction=context gives the user more information. I couldn't find this information anywhere.
Unfortunately this switch still has some bugs, so you can easily run into linker errors. I'm hoping to ultimately make it the default though.
Oct 21 2020
parent MoonlightSentinel <moonlightsentinel disroot.org> writes:
On Thursday, 22 October 2020 at 04:20:35 UTC, Mathias LANG wrote:
 Unfortunately this switch still has some bugs, so you can 
 easily run into linker errors. I'm hoping to ultimately make it 
 the default though.
Which is more of a template emission problem because `-checkaction=context` uses a templated hook in druntime (`core.internal.dassert._d_assert_fail`). `-checkaction=context` should support any unary and binary expression and properly format all data types (unless we've missed some special case). Note that it currently does not support complex expressions (e.g `assert(0 <= a && a < 10);` but I/someone else might implement that in the future.
Oct 22 2020