convert docstring examples to unittests [part 2]#4044
Conversation
|
has anyone an idea why the auto tester is failing for dmd? |
3d04c3d to
a098957
Compare
|
update: it was most likely due to the change in |
|
I think this is also a trivial addition - it just moves unittests from the docs to code :) |
std/algorithm/setops.d
Outdated
| sorted); | ||
| } | ||
|
|
||
| /// |
There was a problem hiding this comment.
The paragraph below the example references the example, but this change moves the example below the text. I think in these cases we need to either leave the example in the doc comment, or restructure the doc text to work with the new layout.
edit:
Historically, before documented unit tests were introduced, we've also left the example in the comment but duplicated the code in a test to make sure it works (and keeps working with future changes). Maybe this approach is still an alternative when examples can't appear at the end of the doc entry. The big disadvantage of this is that it's easy to accidentally edit one but not the other.
There was a problem hiding this comment.
How about moving the two explanation lines as comments into the unittest?
There was a problem hiding this comment.
Sure, you can also put text in the comment for the unit test and it will appear before the example code.
There was a problem hiding this comment.
As this edit might be a bit controversial I moved it over to #4066, so it doesn't block this PR ;-)
|
As a general rule, an important thing to keep in mind when enacting this kind of change is that the documentation text still makes sense with the new ordering of sections. |
a09b04f to
78aac0d
Compare
std/functional.d
Outdated
| unittest | ||
| { | ||
| int fun(int a, int b) { return a + b; } | ||
| alias partial!(fun, 5) fun5; |
There was a problem hiding this comment.
Should use new alias syntax alias x = y; instead of old syntax alias y x.
There was a problem hiding this comment.
oh didn't know that - just copied the old one.
Thanks for the info - updated ;-)
|
The rest of the changes look OK. |
78aac0d to
66e0dc3
Compare
|
LGTM, thanks! |
|
Auto-merge toggled on |
convert docstring examples to unittests [part 2]
in reference to #4042 more converted examples.