Lookahead in unittest

H. S. Teoh via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 12 14:46:30 PDT 2017


On Fri, May 12, 2017 at 05:23:23PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote:
[...]
> Note, you can achieve what you want with version(unittest):
> 
> version(unittest)
> {
>    class A { B b; }
>    class B { }
> }
> 
> unittest
> {
>    // use A and B here
> }
[...]

This advice, unfortunately, needs to be tempered with caution about
namespace pollution and accidental dependency of things outside
unittests on things inside a version(unittest) block.  There's also the
issue of library code introducing extraneous import dependencies that
are really only necessary for unittesting, but get pulled in anyway
because user code happens to compile with -unittest.


T

-- 
"Real programmers can write assembly code in any language. :-)" -- Larry Wall


More information about the Digitalmars-d-learn mailing list