DMD unittest fail reporting…
Chris Wright via Digitalmars-d
digitalmars-d at puremagic.com
Sat Dec 5 19:23:53 PST 2015
I quickly hacked up something to make assertions slightly more verbose:
http://dpaste.dzfl.pl/f94b6ed80b3a
This can be extended quite a bit without a ton of effort, but it would
eventually devolve into fully parsing D using compile-time function
execution. Still, Catch can't even handle logical or, so it should be
trivial to beat it in terms of quality of error reports. No real hope of
matching Spock.
The interface leaves something to be desired:
mixin enforce!(q{i == j});
Say what you will, C preprocessor macros are very low on syntactic
overhead.
The other ways I know of for passing in an expression involve eager
evaluation or convert the expression to an opaque delegate. The mixin is
required in order to access local variables.
The name "enforce" is obviously not appropriate, and it should ideally
have pluggable error reporting mechanisms. But for a first hack, it's not
so bad.
I might clean this up and put it on DUB.
More information about the Digitalmars-d
mailing list