[Issue 22596] The "publictests" target runs unittests at the top-level namespace so they don't have access to

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 14 18:31:55 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22596

--- Comment #6 from moonlightsentinel at disroot.org ---
(In reply to Andrei Alexandrescu from comment #5)

> Allow me to repeat to make sure I understand correctly: no documentation
> unittest nested inside a template in phobos could ever access the template
> parameters. The reason is that those unittests are transformed into runnable
> examples on the website, which are at the top level (hence have no access to
> the enclosing template's arguments).
> 
> That makes sense, I assume it's documented somewhere.

Indeed, but note that this restriction also applies to aggregates for the same
reason (=> example that can be copy + pasted without additional requirements).

> However I see it more of a limitation of the way we go about runnable
> unittests than a "nothing to be seen here" situation.
> 
> [...]
> 
> Well the problem is a tad deeper. The tests need to be run for all versions
> of the standard, that's the whole point of putting them in there. Having
> them check all versions of the standard is great leverage. That we can't do
> that is a serious issue.

The real problem here seems to be a different understanding of documented
unittests. IMO a documented unittests should be an example that demonstrates
the usage of a function/template/... in the most simple way possible without
any strings attached.

Your description matches a great test but doesn't sound like a good example.

> Let's leave this open in search for a good solution.

Providing a default version as outline above could be an acceptable compromise.

--


More information about the Digitalmars-d-bugs mailing list