std.experimental.testing PR review

Atila Neves via Digitalmars-d digitalmars-d at puremagic.com
Wed Jun 3 03:50:41 PDT 2015


On Wednesday, 3 June 2015 at 07:30:31 UTC, Jacob Carlborg wrote:
> On 2015-04-20 15:28, Atila Neves wrote:
>> Original library: http://code.dlang.org/packages/unit-threaded
>> PR: https://github.com/D-Programming-Language/phobos/pull/3207
>
> * Would it be possible to make the "should" functions more 
> composeable. Instead of "a.shouldEqual(b)" something like 
> "a.should.equal(b)". Then you don't need a separate "shouldNot" 
> function for all functions, just one

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.

There's already some controversy over syntax as it is, see 
Dicebot's comments.

> * Is it possible to create custom "should functions" or 
> marchers as RSpec would call them? Otherwise perhaps the above 
> suggestion would make that easier

I'd have to think about that. First we'd have to agree on how 
things should look, though.

> * I would recommend writing the actual operator used for a 
> given "should function" in the documentation

Good idea.

> * Is there a function to compare if two objects are the actual 
> same objects in memory, i.e. comparing using "is"?

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)`.

> * Latest versions of RSpec does not allow to specify an 
> exception type when a test should not throw an exception. I 
> don't recall the exact reason now but it might be worth 
> investigating and taking in to consideration

I might take a look, but really all I've ever seen is expecting 
to throw a particular exception anyway.

> * Is there any special output when running the tests? In that 
> case, how does it look like? Is it possible to use different 
> formatters for the output and create custom ones?

Yes. It looks identical to the library that preceded this, 
unit-threaded. There are examples in the repository for both 
passing and failing tests on purpose to show what the output is 
like.

Atila



More information about the Digitalmars-d mailing list