Thread overview
More elaborate asserts in unittests?
Oct 21, 2020
IGotD-
Oct 21, 2020
Adam D. Ruppe
Oct 21, 2020
IGotD-
Oct 21, 2020
bachmeier
Oct 22, 2020
IGotD-
Oct 22, 2020
Mathias LANG
Oct 22, 2020
MoonlightSentinel
October 21, 2020
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?
October 21, 2020
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
October 21, 2020
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.



October 21, 2020
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.
October 22, 2020
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.
October 22, 2020
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.
October 22, 2020
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.