[Issue 18623] Documented unittest should not allow private symbol access

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat May 5 16:55:01 UTC 2018


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

--- Comment #3 from Nick Treleaven <nick at geany.org> ---
(In reply to Steven Schveighoffer from comment #2)
> You may want to test things inside
> your unit test that have nothing to do with the example, but use the same
> code for setup, and then you have to write that code twice.

If you really want your *documented* unittest not to be runnable by a user, you
can wrap your private code in a free function with `protected` access as a
workaround.

> It's pretty easy to say // private data, for testing only.

The whole point of this issue is for when the programmer is unaware that the
documented example contains private symbols *unintentionally*. This is clearly
a significant problem otherwise @greenify wouldn't have added a custom
automated test for Phobos to check this. Copying and pasting from other tests
is a classic trigger for this.

--


More information about the Digitalmars-d-bugs mailing list