March 27, 2015
On Friday, 27 March 2015 at 19:36:23 UTC, Xavier Bigand wrote:
> Le 27/03/2015 15:02, CraigDillabaugh a écrit :
>> On Friday, 27 March 2015 at 10:10:37 UTC, Dominikus Dittes Scherkl wrote:
clip
>>
>
> Just a little point :
> I find some much examples not tested on Internet, so to me examples have to by played by the compiler in the same time as unittest. Maybe it must have a new keyword?
>
> But that true unittest doesn't have exactly the same purpose and some risk to be hard to read for a beginner.

That is a good point.  Ideally when building a library all the 'examples' in the documentation should be built too to make sure they are still valid.  Example code should be marked as such, extracted and run through the compiler with each new release.  I seem to recall reading in places that some D resources (Ali's book perhaps) do this with their source code.

As things stand that would be a mark in favor of unittests.

March 27, 2015
On Friday, 27 March 2015 at 19:44:10 UTC, CraigDillabaugh wrote:
> That is a good point.  Ideally when building a library all the 'examples' in the documentation should be built too to make sure they are still valid.  Example code should be marked as such, extracted and run through the compiler with each new release.  I seem to recall reading in places that some D resources (Ali's book perhaps) do this with their source code.
>
> As things stand that would be a mark in favor of unittests.

D has documented unittests (they appear in the docs as if part of the Examples section).  The only excuses for example code in Phobos to be untested are supposed to be that it is an incomplete fragment or that it is old code from before we had the feature.

 — David
March 27, 2015
On Friday, 27 March 2015 at 19:47:47 UTC, David Nadlinger wrote:
> On Friday, 27 March 2015 at 19:44:10 UTC, CraigDillabaugh wrote:
>> That is a good point.  Ideally when building a library all the 'examples' in the documentation should be built too to make sure they are still valid.  Example code should be marked as such, extracted and run through the compiler with each new release.  I seem to recall reading in places that some D resources (Ali's book perhaps) do this with their source code.
>>
>> As things stand that would be a mark in favor of unittests.
>
> D has documented unittests (they appear in the docs as if part of the Examples section).  The only excuses for example code in Phobos to be untested are supposed to be that it is an incomplete fragment or that it is old code from before we had the feature.
>
>  — David

Does that force the examples to be unittests though?
March 28, 2015
On Friday, 27 March 2015 at 18:38:32 UTC, rumbu wrote:
> schwartzSort it's a nice name only if you are German.

Hardly. The name's just as meaningless on its own. It may be easier for us Germans to remember the spelling, but even we have to memorize that "tz", as "schwarz" (black) is more common a word.
March 28, 2015
> D has documented unittests (they appear in the docs as if part of the Examples section).  The only excuses for example code in Phobos to be untested are supposed to be that it is an incomplete fragment or that it is old code from before we had the feature.
>
>  — David

I added some just recently, because it wasn't possible to add unittest to the module level.

https://github.com/D-Programming-Language/phobos/blob/master/std/container/package.d
1 2 3
Next ›   Last »