www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Documentation unittests are seriously awesome

reply Nick Sabalausky <SeeWebsiteToContactMe semitwist.com> writes:
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.
Sep 23 2016
next sibling parent "H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> writes:
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
Sep 23 2016
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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
Sep 23 2016
parent "H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> writes:
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 -- Дерево держится корнями, а человек - друзьями.
Sep 25 2016
prev sibling parent reply Anonymouse <asdf asdf.net> writes:
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.)
Sep 26 2016
parent Biotronic <simen.kjaras gmail.com> writes:
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
Sep 26 2016