Documentation unittests are seriously awesome
Biotronic via Digitalmars-d
digitalmars-d at puremagic.com
Mon Sep 26 04:29:34 PDT 2016
On Monday, 26 September 2016 at 09:35:32 UTC, Anonymouse wrote:
> On Friday, 23 September 2016 at 20:42:26 UTC, Nick Sabalausky
> wrote:
>> Just had to say it. Been using it a lot this week.
>>
>> Referring to this stuff:
>>
>> ----------------------------
>> /// Does foo stuff
>> void foo()
>> {}
>>
>> ///
>> unittest
>> {
>> // Tests and docs in one, 2-for-1 win!
>> }
>> ----------------------------
>>
>> And all just built-in. Freaking sweet.
>
> ELI5 please. What does this do and how is it different from
> normal practice? (I assume having the docs together with the
> tests is what's special here.)
Not just together. The code in the unittest block is included
verbatim in the documentation. Basically, it's executable
documentation. :p
This ensures the documentation is up-to-date (otherwise, the
unittests fail) and makes it easy to write documentation since
you're going to write tests anyway (You are going to write tests
anyway, right? Right?).
--
Biotronic
More information about the Digitalmars-d
mailing list