std.experimental.testing PR review

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 4 03:29:59 PDT 2015


On Thursday, 4 June 2015 at 06:33:27 UTC, Jacob Carlborg wrote:
> On 2015-06-03 12:50, Atila Neves wrote:
>
>> Easily. I toyed with this syntax
>>
>> foo().should == 3;
>>
>> And that works. Unfortunately it doesn't work for `!=` or 
>> `>=`. I could
>> do the other operators as compile-time strings, but then `==` 
>> would be
>> the weird one out. In the end I didn't think there was much 
>> value of
>> typing `should.equal` over `shouldEqual` and left it as it is.
>
> The reason would/might be custom "should functions"/matchers.

"would/might"? YAGNI.

>> No, but it'd be easy to write. Is that actually needed though? 
>> It
>> doesn't seem something that would come up often, and one could 
>> always
>> write `&foo.shouldEqual(&bar)`.
>
> I don't know. RSpec has it.

Ruby doesn't have `&`. It's not needed in D.

>> I might take a look, but really all I've ever seen is 
>> expecting to throw
>> a particular exception anyway.
>
> This was for when you're expecting a function to _not_ throw an 
> exception.

I used to think this was useful, probably due to symmetry. In 
practice, it's not. If you want to assert an expression doesn't 
throw, just... write the expression. The test will fail anyway if 
it throws.


Atila


More information about the Digitalmars-d mailing list