-
Notifications
You must be signed in to change notification settings - Fork 149
Done adding Catch with return of Promise #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a98e940
16d9cfb
04f7d76
cf07808
32a1228
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -202,7 +202,10 @@ public void error_handler_is_not_invoked_for_resolved_promised() | |
{ | ||
var promise = new Promise<int>(); | ||
|
||
promise.Catch(e => throw new Exception("This shouldn't happen")); | ||
promise.Catch(e => { | ||
throw new Exception("This shouldn't happen"); | ||
return -1; | ||
}); | ||
|
||
promise.Resolve(5); | ||
} | ||
|
@@ -759,7 +762,6 @@ public void can_chain_promise_and_convert_type_of_value() | |
.Then(v => | ||
{ | ||
Assert.Equal(chainedPromiseValue, v); | ||
|
||
++completed; | ||
}); | ||
|
||
|
@@ -1424,5 +1426,35 @@ public void rejected_reject_callback_is_caught_by_chained_catch() | |
|
||
Assert.Equal(expectedException, actualException); | ||
} | ||
|
||
[Fact] | ||
public void resolved_callback_is_caught_by_catch_returning_promise() { | ||
var promise = new Promise<int>(); | ||
int excepectedValue = 1; | ||
int actualValue = 0; | ||
|
||
promise.Catch(err => Promise<int>.Resolved(-1)) | ||
.Then(result => { actualValue = result; }) | ||
.Catch(err => throw new Exception("Should not happend.")); | ||
|
||
promise.Resolve(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would make more sense here to make the first promise reject and verify that |
||
|
||
Assert.Equal(excepectedValue, actualValue); | ||
} | ||
|
||
[Fact] | ||
public void rejected_callback_is_caught_by_catch_returning_promise() { | ||
var promise = new Promise<int>(); | ||
int excepectedValue = -1; | ||
int actualValue = 0; | ||
|
||
promise.Catch(err => Promise<int>.Rejected(new Exception())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since promise is resolved ( |
||
.Then(result => throw new Exception("Should not happend.")) | ||
.Catch(err => actualValue = -1); | ||
|
||
promise.Resolve(1); | ||
|
||
Assert.Equal(excepectedValue, actualValue); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the promise is resolved, this catch block is never executed.