Creates an ExpectationResult that can be returned by a matcher.
It supports a minimalist way of writing matcher logic, often enabling matchers that in traditional scenarios would have been fairly inelegant to implement, such as toThrowClass().
There are 2 distinct flows for a matcher:
assertion - when the matcher is invoked directly after expect(...)
negation - when the matcher is preceded by expect(...).not()
Each flow can now be analyzed separately - merely returning the error message of the error that the matcher should throw in that case.
To simplify the implementation even more, please refer to the implementBooleanMatcher function, which you should prefer for a fairly wide range of scenarios.
Creates an
ExpectationResult
that can be returned by a matcher.It supports a minimalist way of writing matcher logic, often enabling matchers that in traditional scenarios would have been fairly inelegant to implement, such as toThrowClass().
There are 2 distinct flows for a matcher:
assertion - when the matcher is invoked directly after
expect(...)
negation - when the matcher is preceded by
expect(...).not()
Each flow can now be analyzed separately - merely returning the error message of the error that the matcher should throw in that case.
To simplify the implementation even more, please refer to the implementBooleanMatcher function, which you should prefer for a fairly wide range of scenarios.