You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
prints should accept an optional extra param "then" or similar to validate the result of the provided function #994
This is a reasonable request since prints is not checking the result, but checking side-effects created during the evaluation. You can have many side effects, and still have one result afterward. Other matchers check the result (value or thrown) and there can only be one of those.
Maybe there could be a SideEffectMatcher with an optional Matcher then(Matcher) method and perhaps an SideEffectMatcher and(SideEffectMatcher) for chaining multiple side effects. Example:
We could consider trying to make the allof version work, though taking a look at the implementation that most likely means that the function would get run twice - once to check the prints and once to check the throwsArgumentError.
Making multiple matchers cooperate and only run a Function() once does not look immediately feasible to me.
If it's acceptable to let the function run once per matcher I can run with that. Otherwise we'll likely need a separate approach and provide a different utility.
var printCapture =PrintCapture();
expect(printCapture.wrap(() =>process(1,2,3)), throwsArgumentError);
expect(printCapture.captured, contains('hello'));
On Tue, Mar 5, 2019 at 10:02 AM Nate Bosch ***@***.***> wrote:
We could consider trying to make the allof version work, though taking a
look at the implementation that most likely means that the function would
get run twice - once to check the prints and once to check the
throwsArgumentError.
Making multiple matchers cooperate and only run a Function() once does
not look immediately feasible to me.
If it's acceptable to let the function run once per matcher I can run with
that. Otherwise we'll likely need a separate approach and provide a
different utility.
var printCapture = PrintCapture();expect(printCapture.wrap(() => process(1,2,3)), throwsArgumentError);expect(printCapture.captured, contains('hello'));
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#994 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABCivkDqmbtzZWjYGJMeRY6fdvzsuokks5vTrFBgaJpZM4baMTZ>
.
Activity
grouma commentedon Mar 4, 2019
I'm not sure I follow this request. Can you elaborate with a brief example?
kevmoo commentedon Mar 4, 2019
Fine, but what if I want to check a thrown exception or the result?
lrhn commentedon Mar 4, 2019
This is a reasonable request since
printsis not checking the result, but checking side-effects created during the evaluation. You can have many side effects, and still have one result afterward. Other matchers check the result (value or thrown) and there can only be one of those.Maybe there could be a
SideEffectMatcherwith an optionalMatcher then(Matcher)method and perhaps anSideEffectMatcher and(SideEffectMatcher)for chaining multiple side effects. Example:Then
printswould be aSideEffectMatcher.kevmoo commentedon Mar 4, 2019
@lrhn – SGTM!
natebosch commentedon Mar 5, 2019
Does this work today with
allOf?Would the side effects need to be ordered?
kevmoo commentedon Mar 5, 2019
Tried that. It doesn't work.
natebosch commentedon Mar 5, 2019
We could consider trying to make the
allofversion work, though taking a look at the implementation that most likely means that the function would get run twice - once to check theprintsand once to check thethrowsArgumentError.Making multiple matchers cooperate and only run a
Function()once does not look immediately feasible to me.If it's acceptable to let the function run once per matcher I can run with that. Otherwise we'll likely need a separate approach and provide a different utility.
kevmoo commentedon Mar 5, 2019