Unittest helper module?
Chad J
gamerChad at _spamIsBad_gmail.com
Wed Aug 29 20:55:19 PDT 2007
Nathan Reed wrote:
> Chad J wrote:
>> I also gave a short shot at writing this, and realized that it would
>> need a D expression evaluator, which I don't feel like writing right now.
>
> Couldn't you just use string mixins for this?
>
> Thanks,
> Nathan Reed
Maybe, but I wasn't able to figure out how. If I wasn't interested in
the intermediate values, it'd be easy, but I am interested in the
intermediate values.
This is the problem I run into:
consider
ut.test("foo( foo(a) & foo(b) ) == 0");
Now I'd like to know what foo(a) and foo(b) evaluate to, as well as what
foo(a) & foo(b) evaluates to. So I can just mix that substring in and
evaluate it and grab the value. Then I mixin and evaluate the entire
contents of foo(foo(a)&foo(b)). This is where the problem starts:
foo(a) and foo(b) were just evaluated 2 times, when they should have
only been evaluated once. For pure functions this is fine, but
functions with side effects could break the unittest if this is done.
Using mixins with no analysis causes this foo(...) to be called 10
times, when it should only be called 3 times.
More information about the Digitalmars-d-learn
mailing list