automatically verifying code samples in phobos docs

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 19 18:56:18 PDT 2015


On Thursday, August 20, 2015 02:09:12 Timon Gehr via Digitalmars-d-learn wrote:
> On 08/20/2015 02:02 AM, Laeeth Isharc wrote:
> > On Thursday, 20 August 2015 at 00:00:55 UTC, Timon Gehr wrote:
> >> On 08/20/2015 01:41 AM, Laeeth Isharc wrote:
> >>>
> >>> BTW I don't know why you can't convert a char[] to string - seems
> >>> harmless enough conversion that way around.
> >>
> >> It would need to allocate a new string, otherwise, one would be able
> >> to modify the contents of the immutable string via the char[] reference.
> >
> > and you don't want sneaky allocations creeping in.  ok.  tku.
> >
> > how about automatically checking code in examples?
>
> I think this is the recommended mechanism for that:
> http://dlang.org/unittest.html (documented unit tests)

In general, the code examples are supposed to be unit tests with an empty
ddoc comment on them so that they're unit tested. However, in the case of
std.net.curl, because it would be contacting websites, I doubt that they're
going to be turned into ddoc-ed unit tests.

- Jonathna M Davis



More information about the Digitalmars-d-learn mailing list