On Tuesday, 12 January 2021 at 23:19:45 UTC, Q. Schroll wrote:
On Tuesday, 12 January 2021 at 20:04:00 UTC, Paul Backus wrote:
On Tuesday, 12 January 2021 at 19:49:10 UTC, jmh530 wrote:
I'd rather put the import at the top of the file, or in a
version(unittest) block than that. The problem with those
approaches is that if you have an example unittest, then when
a user tries to run it then they have to put the import in
themselves.
Seems like the obvious solution is to put the import inside
the unittest.
I'd say that example unit tests shouldn't have anything
available except the current module. That a unittest is just a
function is wrong in many ways.
By default, it shouldn't have access to imports outside of it
and it shouldn't have access to non-public (private, package)
symbols.
Agreed. Hence why we had to workaround those language limitations
in phobos with this:
https://github.com/dlang/tools/blob/master/tests_extractor.d