Add a require
function, similar to expect
, which either returns the expression if it passes, or throws if it fails.
#1102
Labels
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())
.The text was updated successfully, but these errors were encountered: