Permalink
Browse files

Add a test case for a nested whenPromise that is missing a rejectCall…

…back. This causes an uncaught exception to be thrown because the error isn't handled on the whenPromise itself, but it is handled later as it bubbles through the promises.
  • Loading branch information...
1 parent f5bb9df commit 498ac694aac7222930847f13e343473f220c5092 @novemberborn novemberborn committed Dec 8, 2010
Showing with 14 additions and 0 deletions.
  1. +14 −0 tests/promise.js
View
@@ -1,5 +1,6 @@
var assert = require("assert"),
when = require("../lib/promise").when,
+ whenPromise = require("../lib/promise").whenPromise,
defer = require("../lib/promise").defer;
exports.testSpeedPlainValue = function(){
@@ -18,6 +19,19 @@ exports.testSpeedPromise = function(){
deferred.resolve(3);
};
+exports.testWhenPromiseRejectHandled = function(){
+ // The inner whenPromise doesn't have a rejectCallback, but the outer one does.
+ // This means the error then *is* handled, but the inner whenPromise doesn't know about that.
+ // This shouldn't result in an uncaught exception thrown by the promise library.
+ whenPromise(true, function(){
+ return whenPromise((function(){
+ var deferred = defer();
+ deferred.reject({});
+ return deferred.promise;
+ })());
+ }).then(null, function(){});
+};
+
if (require.main === module)
require("patr/runner").run(exports);

0 comments on commit 498ac69

Please sign in to comment.