Thread overview
Documentation unittests are seriously awesome
Sep 23, 2016
Nick Sabalausky
Sep 23, 2016
H. S. Teoh
Sep 26, 2016
H. S. Teoh
Sep 26, 2016
Anonymouse
Sep 26, 2016
Biotronic
September 23, 2016
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.
September 23, 2016
On Fri, Sep 23, 2016 at 04:42:26PM -0400, Nick Sabalausky via Digitalmars-d 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.

+1, yep, I love it too. This is one of D's underrated killer features.


T

-- 
Life is complex. It consists of real and imaginary parts. -- YHL
September 23, 2016
On 09/23/2016 04:42 PM, 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.

We owe this to Andrej Mitrovic IIRC! -- Andrei
September 25, 2016
On Fri, Sep 23, 2016 at 08:32:00PM -0400, Andrei Alexandrescu via Digitalmars-d wrote:
> On 09/23/2016 04:42 PM, 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.
> 
> We owe this to Andrej Mitrovic IIRC! -- Andrei

Yes, we do.


T

-- 
Дерево держится корнями, а человек - друзьями.
September 26, 2016
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.)
September 26, 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