← Back to context

Comment by sixthDot

3 hours ago

> Good documentation is good as far as it aids understanding. This might be a side effect of tests, but I don't think it's their goal. A good test will catch breaks in behaviour, I'd never trade completeness for readability in tests, in docs it's the reverse.

The D language standard library uses both. When you generate the documentation from the comments attached to a declaration, the following unittests (they are identified using a special markup, (that is just triple slashes...) are also included.

Example once rendered [0], in the source you see the examples are actually unit tests [1].

[0]: https://dlang.org/phobos/std_algorithm_searching.html#.all

[1]: https://github.com/dlang/phobos/blob/master/std/algorithm/se...