forked from chuntaro/emacs-promise
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
6 changed files
with
85 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 @@ | ||
--ignore-dir=.cask/ |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.elc | ||
*.html | ||
.cask |
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,14 @@ | ||
(source gnu) | ||
(source melpa) | ||
|
||
(package-file "promise.el") | ||
|
||
(depends-on "eieio") | ||
(depends-on "cl-lib") | ||
|
||
(development | ||
(depends-on "f") | ||
(depends-on "ert") | ||
(depends-on "ert-async") | ||
(depends-on "ert-runner") | ||
(depends-on "ert-expectations")) |
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
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,47 @@ | ||
;;; -*- lexical-binding: t -*- | ||
|
||
(ert-deftest-async | ||
test/promise/errors-in-resolver-are-rejections (done) | ||
(promise-done | ||
(promise-chain | ||
(promise-new (lambda (resolve reject) | ||
(error "wut"))) | ||
(then (lambda (result) | ||
(funcall done "Error did not cause promise rejection"))) | ||
(promise-catch (lambda (exception) | ||
(should (equal (error-message-string exception) "wut")) | ||
(funcall done))) | ||
(promise-catch 'done)))) | ||
|
||
(ert-deftest-async | ||
test/promise/errors-in-then-are-rejections (done) | ||
(promise-done | ||
(promise-chain | ||
(promise-new (lambda (resolve reject) | ||
(funcall resolve "yeah"))) | ||
(then (lambda (result) | ||
(error "wut"))) | ||
(then (lambda (result) | ||
(funcall done "Error did not cause promise rejection"))) | ||
(promise-catch (lambda (exception) | ||
(should (equal (error-message-string exception) "wut")) | ||
(funcall done))) | ||
(promise-catch 'done)))) | ||
|
||
(ert-deftest-async | ||
test/promise/resolver-called-synchronously (done) | ||
(let ((chain-constructor-has-finished nil) | ||
(resolver-was-called nil)) | ||
(promise-done | ||
(promise-chain | ||
(promise-new (lambda (resolve reject) | ||
(should (equal chain-constructor-has-finished nil)) | ||
(setq resolver-was-called t) | ||
(funcall resolve 'foo))) | ||
(then (lambda (result) | ||
(should (equal result 'foo)) | ||
(funcall done))) | ||
(promise-catch (lambda (exception) | ||
(funcall done exception)))) | ||
(setq chain-constructor-has-finished t) | ||
(should (equal resolver-was-called t))))) |
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,14 @@ | ||
;;; -*- lexical-binding: t -*- | ||
|
||
(require 'f) | ||
(require 'ert-async) | ||
|
||
(defvar root-test-path | ||
(f-dirname (f-this-file))) | ||
|
||
(defvar root-code-path | ||
(f-parent root-test-path)) | ||
|
||
(add-to-list 'load-path root-code-path) | ||
|
||
(require 'promise) |