documented unit tests as examples
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Fri May 13 14:00:04 PDT 2016
On 5/13/16 4:55 PM, Meta wrote:
> When I was new to D and I first saw the `assert(...)` idiom in an
> example in the documentation, it confused me for a minute or two, but if
> you know what `assert` does you can quickly wrap your head around the
> fact that it's both a test and an example. This would benefit users that
> are completely new to programming in general, however.
Given the fact that asserts aren't always run, it's never comforting to
me to run a program that tests something and have it give NO feedback.
In fact, I frequently find myself triggering the assert to make sure
it's actually being run (and I've caught the build not actually running
it many times).
This has a negative affect on anyone actually looking to see how a D
function works. I can write a program that does nothing easily enough,
why such a complicated example?
-Steve
More information about the Digitalmars-d
mailing list