Dlang tour - Unittesting example

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Oct 2 13:01:56 UTC 2018


On Tuesday, October 2, 2018 3:59:28 AM MDT bauss via Digitalmars-d-learn 
wrote:
> On Tuesday, 2 October 2018 at 04:13:01 UTC, Joe wrote:
> > There appears to be a problem with the example at
> >
> > https://tour.dlang.org/tour/en/gems/unittesting
> >
> > If compiled with -unittest, the resulting program crashes. It
> > happens with ldc2 on Linux but it can also be seen if you click
> > on "Export" and run it with dmd -unittest.
>
> I think it's more likely a problem with your OS.
>
> I am unable to reproduce that with either of dmd or ldc.

IIRC, we use stdc for formatting floating values and not pure D code
(because correctly converting floating point values to strings is really,
really complicated to implement). So, the result is going to depend on the
system that it's run on. It fails on my system (64-bit FreeBSD). Honestly,
this is basically the same thing as comparing floating point values with ==.
You shouldn't do it. So, I'd argue that it's just plain a bad example.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list