Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d08c12
commit 74d8d19
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This tests reported issues in the Promise package | ||
from promise import Promise | ||
|
||
|
||
def test_issue_11(): | ||
# https://github.com/syrusakbary/promise/issues/11 | ||
def test(x): | ||
def my(resolve, reject): | ||
if x > 0: | ||
resolve(x) | ||
else: | ||
reject(Exception(x)) | ||
return Promise(my) | ||
|
||
promise_resolved = test(42).then(lambda x: x) | ||
assert promise_resolved.value == 42 | ||
|
||
promise_rejected = test(-42).then(lambda x: x, lambda e: str(e)) | ||
assert promise_rejected.value == "-42" |