func setUp() throws {
let value = try require(nillableExpression()).toEventuallyNot(beNil())
// ...
}
The require DSL would have a signature similar to expect, only to/toNot/toEventually/etc. would either throw or return the value of the expression.
Bonus: This also gets Nimble functionality similar to XCTUnwrap, which we have been lacking. Admittedly, try expect(someExpression()).toNot(beNil()) is MUCH more verbose than try XCTUnwrap(someExpression()). I think we should ship an unwrap function which essentially calls require(arg).toNot(beNil()). We do a similar thing with the fail matcher. Similarly, we should also ship a simple function for require(arg).toEventuallyNot(beNil()).
Taking some inspiration from swift-testing, I like the idea of the
#require
macro, and feel it would be a really good idea to bring to Nimble.The basic idea is to replace a lot of setup code that looks like:
with something like this:
The
require
DSL would have a signature similar toexpect
, onlyto
/toNot
/toEventually
/etc. would either throw or return the value of the expression.Bonus: This also gets Nimble functionality similar to XCTUnwrap, which we have been lacking. Admittedly,
try expect(someExpression()).toNot(beNil())
is MUCH more verbose thantry XCTUnwrap(someExpression())
. I think we should ship anunwrap
function which essentially callsrequire(arg).toNot(beNil())
. We do a similar thing with thefail
matcher. Similarly, we should also ship a simple function forrequire(arg).toEventuallyNot(beNil())
.