Browse Source

Fixed: promise late chain

v0.7.4-release
Yuichiro MASUI 15 years ago
committed by Ryan Dahl
parent
commit
1793ee1c80
  1. 2
      src/node.js
  2. 12
      test/mjsunit/test-promise.js

2
src/node.js

@ -264,7 +264,7 @@ var eventsModule = createInternalModule('events', function (exports) {
exports.Promise.prototype.addCallback = function (listener) { exports.Promise.prototype.addCallback = function (listener) {
if (this.hasFired === 'success') { if (this.hasFired === 'success') {
return listener.apply(this, this._values); listener.apply(this, this._values);
} }
return this.addListener("success", listener); return this.addListener("success", listener);

12
test/mjsunit/test-promise.js

@ -24,13 +24,13 @@ a.addErrback(function(error) {
}); });
a.emitSuccess(TEST_VALUE); a.emitSuccess(TEST_VALUE);
a.addCallback(function(value) { assert.ok(a.addCallback(function(value) {
assert.equal(TEST_VALUE, value); assert.equal(TEST_VALUE, value);
expectedCallbacks.a2--; expectedCallbacks.a2--;
}); }));
a.addErrback(function(error) { assert.ok(a.addErrback(function(error) {
assert.notEqual(TEST_VALUE, error, 'late'); assert.notEqual(TEST_VALUE, error, 'late');
}); }));
// Test regular & late errback binding // Test regular & late errback binding
var b = new Promise(); var b = new Promise();
@ -48,10 +48,10 @@ b.addErrback(function(value) {
// Test late errback binding // Test late errback binding
var c = new Promise(); var c = new Promise();
c.emitError(TEST_VALUE); c.emitError(TEST_VALUE);
c.addErrback(function(value) { assert.ok(c.addErrback(function(value) {
assert.equal(TEST_VALUE, value); assert.equal(TEST_VALUE, value);
expectedCallbacks.c1--; expectedCallbacks.c1--;
}); }));
// Test errback exceptions // Test errback exceptions
var d = new Promise(); var d = new Promise();

Loading…
Cancel
Save