https://issues.dlang.org/show_bug.cgi?id=22596
Andrei Alexandrescu <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID |--- --- Comment #3 from Andrei Alexandrescu <[email protected]> --- (In reply to moonlightsentinel from comment #2) > A documented unittest as defined above would contribute the following to the > documentation: > > Example: > ------------------- > writeln(v); > ------------------ > > Note that the symbol `v` is entirely undefined - so the test is failing as > expected. A user should be able to execute code shown in a documented > unittest by simply adding the appropriate import. > > Any unittest that relies on internal details of a module / it's members > (which are not accessible when importing said module) should be private. > This also applies to the template parameter `v`. The symbol is not undefined because the documentation is nested inside the `canon` template, which is parameterized on v. Maybe I simplified the code too much. Expanding it a bit: /// Module. import std.stdio; /// This is a template parameterized on value `v`. template canon(string v) { /// This is a function that does something. void fun(string); /// This is a unittest that shows how to use the function unittest { fun(v ~ "!"); } } void main() { canon!"hello".fun(""); } Looking at the generated html documentation, the declaration of canon is shown first. Nested within is the example. Does this work properly with `make publictests`? --
