Let's bikeshed std.experimental.testing assertions/checks/whatchamacallits

Jesse Phillips via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 30 17:26:20 PDT 2015


On Tuesday, 30 June 2015 at 11:43:36 UTC, Dicebot wrote:
> In absence of language changes, I don't see anything as clear 
> and simple as operator mixins. Less magic in unittests -> 
> better. Common misconception IMHO is that tests should look 
> nice for library/app author, while, from the ecosystem PoV, 
> they should look simple and predictable for contributors - and 
> that is most important property.

I tend to agree with your position on testing frameworks. It 
seems really cool to utilize English to spell out an expectation, 
but it ends up more complicated. For one, it can never actually 
be English (I wouldn't want it to be) and for another, I've 
already got expressions from the language being used that mean 
the same thing.

     unittest {
         struct A {
             int m;
         }

         A a;
         A b;
         a.m = 5;
         b.m = 5;

         auto testA = a.test;
         with(testA) {
             verify(testA.lhs == b);
             b.m = 6;
             verify(testA.lhs != b);
             verify(testA.lhs == b);
         }
     }

It is kind of like what you're saying, but the condition isn't 
reportable. I'm actually less concerned about the condition as I 
am being able to report all the values utilized by the condition. 
I'd like to see assert be more descriptive or a framework that 
looks like assert and is more descriptive. Here is the crap code 
to run the above:

https://gist.github.com/JesseKPhillips/df79479cbf6a0e3c6b0d


More information about the Digitalmars-d mailing list