std.unittests for (final?) review

Ary Borenszweig ary at esperanto.org.ar
Wed Jan 5 18:54:32 PST 2011


I prefer assert, assertFalse, assertEqual and assertNotEqual.

Compare this:
assertPredicate!"a < b"(1 + 1, 3);

To this:
assert(1 + 1 < 3)

Or to this:

assertLess(1 + 1, 3)

Ok, the first one is more generic. But so the error message for the assertion failure will be more generic, when you want exactly the opposite to happen.
Plus your brain has to think more to read it (starting from the point that it's longer).

assertPredicate!"<"(1 + 1, 3) reminds me of polish notation, which is very good for machines but not very good for humans.

Sorry, you can have more specific error messages: on compile time you parse the given string and see. If it's "<" then you give an error message regarding
less. Then you end up having a huge function, bearly understandable, and with a huge documentation. On the other case you end up having very well defined
functions, very simple to read and write, well documented, and also with a very simple implementation. What's the benefit of inlining all of that if it's
going to be used in unit tests or in debug mode?

I'm not a big fan of IDEs anymore but having many functions also helps with the autocompletion, to get the code right on the first shot, instead of
assertPredicate!insertYourStringHere(...).


More information about the Digitalmars-d mailing list