Skip to content

Instantly share code, notes, and snippets.

@masuidrive
Created February 13, 2010 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save masuidrive/303396 to your computer and use it in GitHub Desktop.
Save masuidrive/303396 to your computer and use it in GitHub Desktop.
patch for Node.js
From 0679d20b600ffabbb8341eab6cae733696e6ff06 Mon Sep 17 00:00:00 2001
From: Yuichiro MASUI <masui@masuidrive.jp>
Date: Sat, 13 Feb 2010 03:27:01 -0800
Subject: [PATCH] Fixed: promise late chain
---
src/node.js | 2 +-
test/mjsunit/test-promise.js | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/node.js b/src/node.js
index 052651d..e31e000 100644
--- a/src/node.js
+++ b/src/node.js
@@ -264,7 +264,7 @@ var eventsModule = createInternalModule('events', function (exports) {
exports.Promise.prototype.addCallback = function (listener) {
if (this.hasFired === 'success') {
- return listener.apply(this, this._values);
+ listener.apply(this, this._values);
}
return this.addListener("success", listener);
diff --git a/test/mjsunit/test-promise.js b/test/mjsunit/test-promise.js
index 2992f93..149c07e 100644
--- a/test/mjsunit/test-promise.js
+++ b/test/mjsunit/test-promise.js
@@ -24,13 +24,13 @@ a.addErrback(function(error) {
});
a.emitSuccess(TEST_VALUE);
-a.addCallback(function(value) {
+assert.ok(a.addCallback(function(value) {
assert.equal(TEST_VALUE, value);
expectedCallbacks.a2--;
-});
-a.addErrback(function(error) {
+}));
+assert.ok(a.addErrback(function(error) {
assert.notEqual(TEST_VALUE, error, 'late');
-});
+}));
// Test regular & late errback binding
var b = new Promise();
@@ -48,10 +48,10 @@ b.addErrback(function(value) {
// Test late errback binding
var c = new Promise();
c.emitError(TEST_VALUE);
-c.addErrback(function(value) {
+assert.ok(c.addErrback(function(value) {
assert.equal(TEST_VALUE, value);
expectedCallbacks.c1--;
-});
+}));
// Test errback exceptions
var d = new Promise();
--
1.6.6.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment