mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 16:04:36 +02:00
built-ins/Promise/*: make all indentation consistent (depth & character) (#1433)
This commit is contained in:
parent
8d54ea55ad
commit
133dfa8793
@ -10,5 +10,5 @@ description: Promise.call("non-object") throws TypeError
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.call("non-object", function () {});
|
Promise.call("non-object", function() {});
|
||||||
});
|
});
|
||||||
|
@ -11,6 +11,6 @@ description: Promise.call(new Promise()) throws TypeError
|
|||||||
|
|
||||||
var p = new Promise(function() {});
|
var p = new Promise(function() {});
|
||||||
|
|
||||||
assert.throws(TypeError, function () {
|
assert.throws(TypeError, function() {
|
||||||
Promise.call(p, function () {});
|
Promise.call(p, function() {});
|
||||||
});
|
});
|
||||||
|
@ -10,13 +10,15 @@ description: Promise.call(resolved Promise) throws TypeError
|
|||||||
flags: [async]
|
flags: [async]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var p = new Promise(function(resolve) { resolve(1); });
|
var p = new Promise(function(resolve) {
|
||||||
|
resolve(1);
|
||||||
|
});
|
||||||
|
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
Promise.call(p, function () {});
|
Promise.call(p, function() {});
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
$ERROR("Unexpected resolution - expected TypeError");
|
$ERROR("Unexpected resolution - expected TypeError");
|
||||||
}, function (err) {
|
}, function(err) {
|
||||||
if (!(err instanceof TypeError)) {
|
if (!(err instanceof TypeError)) {
|
||||||
$ERROR("Expected TypeError, got " + err);
|
$ERROR("Expected TypeError, got " + err);
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,15 @@ description: Promise.call(rejected Promise) throws TypeError
|
|||||||
flags: [async]
|
flags: [async]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var p = new Promise(function(resolve, reject) { reject(1) });
|
var p = new Promise(function(resolve, reject) {
|
||||||
|
reject(1)
|
||||||
|
});
|
||||||
|
|
||||||
p.catch(function () {
|
p.catch(function() {
|
||||||
Promise.call(p, function () {});
|
Promise.call(p, function() {});
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
$ERROR("Unexpected resolution - expected TypeError");
|
$ERROR("Unexpected resolution - expected TypeError");
|
||||||
}, function (err) {
|
}, function(err) {
|
||||||
if (!(err instanceof TypeError)) {
|
if (!(err instanceof TypeError)) {
|
||||||
$ERROR("Expected TypeError, got " + err);
|
$ERROR("Expected TypeError, got " + err);
|
||||||
}
|
}
|
||||||
|
@ -12,15 +12,14 @@ flags: [async]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var errorObject = {},
|
var errorObject = {},
|
||||||
p = new Promise(function () {
|
p = new Promise(function() {
|
||||||
throw errorObject;
|
throw errorObject;
|
||||||
});
|
});
|
||||||
|
|
||||||
p.then(function() {
|
p.then(function() {
|
||||||
$ERROR("Unexpected fulfill -- promise should reject.");
|
$ERROR("Unexpected fulfill -- promise should reject.");
|
||||||
}, function (err) {
|
}, function(err) {
|
||||||
if (err !== errorObject) {
|
if (err !== errorObject) {
|
||||||
$ERROR("Expected promise rejection reason to be thrown errorObject, actually " + err);
|
$ERROR("Expected promise rejection reason to be thrown errorObject, actually " + err);
|
||||||
}
|
}
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ flags: [async, noStrict]
|
|||||||
|
|
||||||
var expectedThis = this;
|
var expectedThis = this;
|
||||||
|
|
||||||
var p = new Promise(function (resolve) {
|
var p = new Promise(function(resolve) {
|
||||||
if (this !== expectedThis) {
|
if (this !== expectedThis) {
|
||||||
$ERROR("'this' must be global object, got " + this);
|
$ERROR("'this' must be global object, got " + this);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ flags: [async, onlyStrict]
|
|||||||
|
|
||||||
var expectedThis = undefined;
|
var expectedThis = undefined;
|
||||||
|
|
||||||
var p = new Promise(function (resolve) {
|
var p = new Promise(function(resolve) {
|
||||||
if (this !== expectedThis) {
|
if (this !== expectedThis) {
|
||||||
$ERROR("'this' must be undefined, got " + this);
|
$ERROR("'this' must be undefined, got " + this);
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ flags: [async]
|
|||||||
|
|
||||||
var sequence = [];
|
var sequence = [];
|
||||||
|
|
||||||
Promise.all([]).then(function () {
|
Promise.all([]).then(function() {
|
||||||
sequence.push(2);
|
sequence.push(2);
|
||||||
}).catch($DONE);
|
}).catch($DONE);
|
||||||
|
|
||||||
Promise.resolve().then(function() {
|
Promise.resolve().then(function() {
|
||||||
sequence.push(3);
|
sequence.push(3);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
sequence.push(4);
|
sequence.push(4);
|
||||||
checkSequence(sequence, "Promises resolved in unexpected sequence");
|
checkSequence(sequence, "Promises resolved in unexpected sequence");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -11,8 +11,8 @@ flags: [async]
|
|||||||
|
|
||||||
var arg = [];
|
var arg = [];
|
||||||
|
|
||||||
Promise.all(arg).then(function (result) {
|
Promise.all(arg).then(function(result) {
|
||||||
if(!(result instanceof Array)) {
|
if (!(result instanceof Array)) {
|
||||||
$ERROR("expected an array from Promise.all, got " + result);
|
$ERROR("expected an array from Promise.all, got " + result);
|
||||||
}
|
}
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -11,8 +11,8 @@ flags: [async]
|
|||||||
|
|
||||||
var arg = [];
|
var arg = [];
|
||||||
|
|
||||||
Promise.all(arg).then(function (result) {
|
Promise.all(arg).then(function(result) {
|
||||||
if(result.length !== 0) {
|
if (result.length !== 0) {
|
||||||
$ERROR("expected an empty array from Promise.all([]), got " + result);
|
$ERROR("expected an empty array from Promise.all([]), got " + result);
|
||||||
}
|
}
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -11,8 +11,8 @@ flags: [async]
|
|||||||
|
|
||||||
var arg = [];
|
var arg = [];
|
||||||
|
|
||||||
Promise.all(arg).then(function (result) {
|
Promise.all(arg).then(function(result) {
|
||||||
if(result === arg) {
|
if (result === arg) {
|
||||||
$ERROR("expected a new array from Promise.all but argument was re-used");
|
$ERROR("expected a new array from Promise.all but argument was re-used");
|
||||||
}
|
}
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -14,9 +14,9 @@ flags: [async]
|
|||||||
|
|
||||||
var nonIterable = 3;
|
var nonIterable = 3;
|
||||||
|
|
||||||
Promise.all(nonIterable).then(function () {
|
Promise.all(nonIterable).then(function() {
|
||||||
$ERROR('Promise unexpectedly resolved: Promise.all(nonIterable) should throw TypeError');
|
$ERROR('Promise unexpectedly resolved: Promise.all(nonIterable) should throw TypeError');
|
||||||
},function (err) {
|
}, function(err) {
|
||||||
if (!(err instanceof TypeError)) {
|
if (!(err instanceof TypeError)) {
|
||||||
$ERROR('Expected TypeError, got ' + err);
|
$ERROR('Expected TypeError, got ' + err);
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,10 @@ description: Promise.all(new Error()) returns Promise rejected with TypeError
|
|||||||
flags: [async]
|
flags: [async]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
Promise.all(new Error("abrupt")).then(function () {
|
Promise.all(new Error("abrupt")).then(function() {
|
||||||
$ERROR('Promise unexpectedly resolved: Promise.all(abruptCompletion) should throw TypeError');
|
$ERROR('Promise unexpectedly resolved: Promise.all(abruptCompletion) should throw TypeError');
|
||||||
},function (err) {
|
}, function(err) {
|
||||||
if (!(err instanceof TypeError)) {
|
if (!(err instanceof TypeError)) {
|
||||||
$ERROR('Expected TypeError, got ' + err);
|
$ERROR('Expected TypeError, got ' + err);
|
||||||
}
|
}
|
||||||
}).then($DONE,$DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -14,15 +14,15 @@ flags: [async]
|
|||||||
|
|
||||||
var iterThrows = {};
|
var iterThrows = {};
|
||||||
Object.defineProperty(iterThrows, Symbol.iterator, {
|
Object.defineProperty(iterThrows, Symbol.iterator, {
|
||||||
get: function () {
|
get: function() {
|
||||||
throw new Error("abrupt completion");
|
throw new Error("abrupt completion");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all(iterThrows).then(function () {
|
Promise.all(iterThrows).then(function() {
|
||||||
$ERROR('Promise unexpectedly fulfilled: Promise.all(iterThrows) should throw TypeError');
|
$ERROR('Promise unexpectedly fulfilled: Promise.all(iterThrows) should throw TypeError');
|
||||||
},function (err) {
|
}, function(err) {
|
||||||
if (!(err instanceof Error)) {
|
if (!(err instanceof Error)) {
|
||||||
$ERROR('Expected promise to be rejected with error, got ' + err);
|
$ERROR('Expected promise to be rejected with error, got ' + err);
|
||||||
}
|
}
|
||||||
}).then($DONE,$DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -9,8 +9,7 @@ description: this must conform to Promise constructor in Promise.all
|
|||||||
author: Sam Mikes
|
author: Sam Mikes
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function ZeroArgConstructor() {
|
function ZeroArgConstructor() {}
|
||||||
}
|
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.all.call(ZeroArgConstructor, []);
|
Promise.all.call(ZeroArgConstructor, []);
|
||||||
|
@ -16,14 +16,14 @@ var iterThrows = {};
|
|||||||
var error = new Test262Error();
|
var error = new Test262Error();
|
||||||
iterThrows[Symbol.iterator] = function() {
|
iterThrows[Symbol.iterator] = function() {
|
||||||
return {
|
return {
|
||||||
next: function () {
|
next: function() {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.all(iterThrows).then(function () {
|
Promise.all(iterThrows).then(function() {
|
||||||
$ERROR('Promise unexpectedly resolved: Promise.all(iterThrows) should throw TypeError');
|
$ERROR('Promise unexpectedly resolved: Promise.all(iterThrows) should throw TypeError');
|
||||||
},function (reason) {
|
}, function(reason) {
|
||||||
assert.sameValue(reason, error);
|
assert.sameValue(reason, error);
|
||||||
}).then($DONE,$DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -13,7 +13,7 @@ flags: [async]
|
|||||||
|
|
||||||
var p = Promise.all([]);
|
var p = Promise.all([]);
|
||||||
|
|
||||||
p.then(function (result) {
|
p.then(function(result) {
|
||||||
if (!(result instanceof Array)) {
|
if (!(result instanceof Array)) {
|
||||||
$ERROR("Expected Promise.all([]) to be Array, actually " + result);
|
$ERROR("Expected Promise.all([]) to be Array, actually " + result);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ var p1 = Promise.resolve(3);
|
|||||||
|
|
||||||
var pAll = Promise.all([p1]);
|
var pAll = Promise.all([p1]);
|
||||||
|
|
||||||
pAll.then(function (result) {
|
pAll.then(function(result) {
|
||||||
if (!(pAll instanceof Promise)) {
|
if (!(pAll instanceof Promise)) {
|
||||||
$ERROR("Expected Promise.all() to be promise, actually " + pAll);
|
$ERROR("Expected Promise.all() to be promise, actually " + pAll);
|
||||||
}
|
}
|
||||||
|
@ -14,19 +14,21 @@ flags: [async]
|
|||||||
|
|
||||||
var sequence = [];
|
var sequence = [];
|
||||||
|
|
||||||
var p1 = new Promise(function (resolve) { resolve({}); } );
|
var p1 = new Promise(function(resolve) {
|
||||||
|
resolve({});
|
||||||
|
});
|
||||||
|
|
||||||
sequence.push(1);
|
sequence.push(1);
|
||||||
|
|
||||||
Promise.all([p1]).then(function (resolved) {
|
Promise.all([p1]).then(function(resolved) {
|
||||||
sequence.push(4);
|
sequence.push(4);
|
||||||
checkSequence(sequence, "Expected Promise.all().then to queue second");
|
checkSequence(sequence, "Expected Promise.all().then to queue second");
|
||||||
}).catch($DONE);
|
}).catch($DONE);
|
||||||
|
|
||||||
p1.then(function () {
|
p1.then(function() {
|
||||||
sequence.push(3);
|
sequence.push(3);
|
||||||
checkSequence(sequence, "Expected p1.then to queue first");
|
checkSequence(sequence, "Expected p1.then to queue first");
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
sequence.push(5);
|
sequence.push(5);
|
||||||
checkSequence(sequence, "Expected final then to queue last");
|
checkSequence(sequence, "Expected final then to queue last");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -11,22 +11,26 @@ flags: [async]
|
|||||||
|
|
||||||
var sequence = [];
|
var sequence = [];
|
||||||
|
|
||||||
var p1 = new Promise(function (resolve) { resolve(1); } );
|
var p1 = new Promise(function(resolve) {
|
||||||
var p2 = new Promise(function (resolve) { resolve(2); } );
|
resolve(1);
|
||||||
|
});
|
||||||
|
var p2 = new Promise(function(resolve) {
|
||||||
|
resolve(2);
|
||||||
|
});
|
||||||
|
|
||||||
sequence.push(1);
|
sequence.push(1);
|
||||||
|
|
||||||
p1.then(function () {
|
p1.then(function() {
|
||||||
sequence.push(3);
|
sequence.push(3);
|
||||||
checkSequence(sequence, "Expected to be called first.");
|
checkSequence(sequence, "Expected to be called first.");
|
||||||
}).catch($DONE);
|
}).catch($DONE);
|
||||||
|
|
||||||
Promise.all([p1, p2]).then(function () {
|
Promise.all([p1, p2]).then(function() {
|
||||||
sequence.push(5);
|
sequence.push(5);
|
||||||
checkSequence(sequence, "Expected to be called third.");
|
checkSequence(sequence, "Expected to be called third.");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
|
||||||
p2.then(function () {
|
p2.then(function() {
|
||||||
sequence.push(4);
|
sequence.push(4);
|
||||||
checkSequence(sequence, "Expected to be called second.");
|
checkSequence(sequence, "Expected to be called second.");
|
||||||
}).catch($DONE);
|
}).catch($DONE);
|
||||||
|
@ -11,14 +11,14 @@ flags: [async]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var rejectP1,
|
var rejectP1,
|
||||||
p1 = new Promise(function (resolve, reject) {
|
p1 = new Promise(function(resolve, reject) {
|
||||||
rejectP1 = reject;
|
rejectP1 = reject;
|
||||||
}),
|
}),
|
||||||
p2 = Promise.resolve(2);
|
p2 = Promise.resolve(2);
|
||||||
|
|
||||||
Promise.all([p1, p2]).then(function (resolve) {
|
Promise.all([p1, p2]).then(function(resolve) {
|
||||||
$ERROR("Did not expect promise to be fulfilled.");
|
$ERROR("Did not expect promise to be fulfilled.");
|
||||||
}, function (rejected) {
|
}, function(rejected) {
|
||||||
if (rejected !== 1) {
|
if (rejected !== 1) {
|
||||||
$ERROR("Expected promise to be rejected with 1, actually " + rejected);
|
$ERROR("Expected promise to be rejected with 1, actually " + rejected);
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,13 @@ flags: [async]
|
|||||||
|
|
||||||
var rejectP2,
|
var rejectP2,
|
||||||
p1 = Promise.resolve(1),
|
p1 = Promise.resolve(1),
|
||||||
p2 = new Promise(function (resolve, reject) {
|
p2 = new Promise(function(resolve, reject) {
|
||||||
rejectP2 = reject;
|
rejectP2 = reject;
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all([p1, p2]).then(function () {
|
Promise.all([p1, p2]).then(function() {
|
||||||
$ERROR("Did not expect promise to be fulfilled.");
|
$ERROR("Did not expect promise to be fulfilled.");
|
||||||
}, function (rejected) {
|
}, function(rejected) {
|
||||||
if (rejected !== 2) {
|
if (rejected !== 2) {
|
||||||
$ERROR("Expected promise to be rejected with 2, actually " + rejected);
|
$ERROR("Expected promise to be rejected with 2, actually " + rejected);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,9 @@ function Constructor(executor) {
|
|||||||
}
|
}
|
||||||
executor(resolve, $ERROR);
|
executor(resolve, $ERROR);
|
||||||
}
|
}
|
||||||
Constructor.resolve = function(v) { return v; };
|
Constructor.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
var p1OnFulfilled;
|
var p1OnFulfilled;
|
||||||
|
|
||||||
|
@ -26,7 +26,9 @@ function Constructor(executor) {
|
|||||||
}
|
}
|
||||||
executor(resolve, $ERROR);
|
executor(resolve, $ERROR);
|
||||||
}
|
}
|
||||||
Constructor.resolve = function(v) { return v; };
|
Constructor.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
var p1 = {
|
var p1 = {
|
||||||
then: function(onFulfilled, onRejected) {
|
then: function(onFulfilled, onRejected) {
|
||||||
|
@ -25,7 +25,9 @@ function Constructor(executor) {
|
|||||||
}
|
}
|
||||||
executor(resolve, $ERROR);
|
executor(resolve, $ERROR);
|
||||||
}
|
}
|
||||||
Constructor.resolve = function(v) { return v; };
|
Constructor.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
var p1 = {
|
var p1 = {
|
||||||
then: function(onFulfilled, onRejected) {
|
then: function(onFulfilled, onRejected) {
|
||||||
|
@ -27,7 +27,7 @@ Promise.all.call(function(executor) {
|
|||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor();
|
executor();
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
}, []);
|
}, []);
|
||||||
assert.sameValue(checkPoint, "abc", "executor initially called with no arguments");
|
assert.sameValue(checkPoint, "abc", "executor initially called with no arguments");
|
||||||
@ -37,7 +37,7 @@ Promise.all.call(function(executor) {
|
|||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(undefined, undefined);
|
executor(undefined, undefined);
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
}, []);
|
}, []);
|
||||||
assert.sameValue(checkPoint, "abc", "executor initially called with (undefined, undefined)");
|
assert.sameValue(checkPoint, "abc", "executor initially called with (undefined, undefined)");
|
||||||
@ -46,9 +46,9 @@ var checkPoint = "";
|
|||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.all.call(function(executor) {
|
Promise.all.call(function(executor) {
|
||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(undefined, function(){});
|
executor(undefined, function() {});
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
}, []);
|
}, []);
|
||||||
}, "executor initially called with (undefined, function)");
|
}, "executor initially called with (undefined, function)");
|
||||||
@ -58,9 +58,9 @@ var checkPoint = "";
|
|||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.all.call(function(executor) {
|
Promise.all.call(function(executor) {
|
||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(function(){}, undefined);
|
executor(function() {}, undefined);
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
}, []);
|
}, []);
|
||||||
}, "executor initially called with (function, undefined)");
|
}, "executor initially called with (function, undefined)");
|
||||||
@ -72,7 +72,7 @@ assert.throws(TypeError, function() {
|
|||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor("invalid value", 123);
|
executor("invalid value", 123);
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
}, []);
|
}, []);
|
||||||
}, "executor initially called with (String, Number)");
|
}, "executor initially called with (String, Number)");
|
||||||
|
@ -56,7 +56,7 @@ var checkPoint = "";
|
|||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.all.call(function(executor) {
|
Promise.all.call(function(executor) {
|
||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(undefined, function(){});
|
executor(undefined, function() {});
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
}, []);
|
}, []);
|
||||||
}, "executor called with (undefined, function)");
|
}, "executor called with (undefined, function)");
|
||||||
@ -66,7 +66,7 @@ var checkPoint = "";
|
|||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.all.call(function(executor) {
|
Promise.all.call(function(executor) {
|
||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(function(){}, undefined);
|
executor(function() {}, undefined);
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
}, []);
|
}, []);
|
||||||
}, "executor called with (function, undefined)");
|
}, "executor called with (function, undefined)");
|
||||||
|
@ -50,7 +50,9 @@ var iter = {};
|
|||||||
iter[Symbol.iterator] = function() {
|
iter[Symbol.iterator] = function() {
|
||||||
return {
|
return {
|
||||||
next: function() {
|
next: function() {
|
||||||
return { done: true };
|
return {
|
||||||
|
done: true
|
||||||
|
};
|
||||||
},
|
},
|
||||||
return: function() {
|
return: function() {
|
||||||
returnCount += 1;
|
returnCount += 1;
|
||||||
@ -60,7 +62,9 @@ iter[Symbol.iterator] = function() {
|
|||||||
};
|
};
|
||||||
var P = function(executor) {
|
var P = function(executor) {
|
||||||
return new Promise(function(_, reject) {
|
return new Promise(function(_, reject) {
|
||||||
executor(function() { throw new Test262Error(); }, reject);
|
executor(function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}, reject);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,7 +48,9 @@ flags: [async]
|
|||||||
var thrown = new Test262Error();
|
var thrown = new Test262Error();
|
||||||
var P = function(executor) {
|
var P = function(executor) {
|
||||||
return new Promise(function(_, reject) {
|
return new Promise(function(_, reject) {
|
||||||
executor(function() { throw thrown; }, reject);
|
executor(function() {
|
||||||
|
throw thrown;
|
||||||
|
}, reject);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,4 +33,6 @@ Object.defineProperty(Array.prototype, 0, {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.all([42]).then(function(){ $DONE(); }, $DONE);
|
Promise.all([42]).then(function() {
|
||||||
|
$DONE();
|
||||||
|
}, $DONE);
|
||||||
|
@ -30,7 +30,10 @@ var callCount = 0;
|
|||||||
iterDoneSpy[Symbol.iterator] = function() {
|
iterDoneSpy[Symbol.iterator] = function() {
|
||||||
return {
|
return {
|
||||||
next: function() {
|
next: function() {
|
||||||
return { value: null, done: false };
|
return {
|
||||||
|
value: null,
|
||||||
|
done: false
|
||||||
|
};
|
||||||
},
|
},
|
||||||
return: function() {
|
return: function() {
|
||||||
callCount += 1;
|
callCount += 1;
|
||||||
|
@ -30,7 +30,9 @@ var returnCount = 0;
|
|||||||
iter[Symbol.iterator] = function() {
|
iter[Symbol.iterator] = function() {
|
||||||
return {
|
return {
|
||||||
next: function() {
|
next: function() {
|
||||||
return { done: false };
|
return {
|
||||||
|
done: false
|
||||||
|
};
|
||||||
},
|
},
|
||||||
return: function() {
|
return: function() {
|
||||||
returnCount += 1;
|
returnCount += 1;
|
||||||
|
@ -31,7 +31,10 @@ var iter = {};
|
|||||||
iter[Symbol.iterator] = function() {
|
iter[Symbol.iterator] = function() {
|
||||||
return {
|
return {
|
||||||
next: function() {
|
next: function() {
|
||||||
return { done: false, value: promise };
|
return {
|
||||||
|
done: false,
|
||||||
|
value: promise
|
||||||
|
};
|
||||||
},
|
},
|
||||||
return: function() {
|
return: function() {
|
||||||
returnCount += 1;
|
returnCount += 1;
|
||||||
|
@ -31,7 +31,10 @@ var iter = {};
|
|||||||
iter[Symbol.iterator] = function() {
|
iter[Symbol.iterator] = function() {
|
||||||
return {
|
return {
|
||||||
next: function() {
|
next: function() {
|
||||||
return { done: false, value: promise };
|
return {
|
||||||
|
done: false,
|
||||||
|
value: promise
|
||||||
|
};
|
||||||
},
|
},
|
||||||
return: function() {
|
return: function() {
|
||||||
returnCount += 1;
|
returnCount += 1;
|
||||||
|
@ -15,14 +15,17 @@ info: |
|
|||||||
...
|
...
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function resolveFunction() { }
|
function resolveFunction() {}
|
||||||
|
|
||||||
function Constructor(executor) {
|
function Constructor(executor) {
|
||||||
executor(resolveFunction, $ERROR);
|
executor(resolveFunction, $ERROR);
|
||||||
}
|
}
|
||||||
Constructor.resolve = function(v) { return v; };
|
Constructor.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
var callCount1 = 0, callCount2 = 0;
|
var callCount1 = 0,
|
||||||
|
callCount2 = 0;
|
||||||
var p1OnFulfilled;
|
var p1OnFulfilled;
|
||||||
|
|
||||||
var p1 = {
|
var p1 = {
|
||||||
|
@ -25,7 +25,9 @@ flags: [async]
|
|||||||
|
|
||||||
var thenable = {
|
var thenable = {
|
||||||
then: function(_, reject) {
|
then: function(_, reject) {
|
||||||
new Promise(function(resolve) { resolve(); })
|
new Promise(function(resolve) {
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
reject();
|
reject();
|
||||||
});
|
});
|
||||||
|
@ -30,7 +30,9 @@ flags: [async]
|
|||||||
|
|
||||||
var fulfiller = {
|
var fulfiller = {
|
||||||
then: function(resolve) {
|
then: function(resolve) {
|
||||||
new Promise(function(resolve) { resolve(); })
|
new Promise(function(resolve) {
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
@ -38,7 +40,9 @@ var fulfiller = {
|
|||||||
};
|
};
|
||||||
var rejector = {
|
var rejector = {
|
||||||
then: function(resolve, reject) {
|
then: function(resolve, reject) {
|
||||||
new Promise(function(resolve) { resolve(); })
|
new Promise(function(resolve) {
|
||||||
|
resolve();
|
||||||
|
})
|
||||||
.then(function() {
|
.then(function() {
|
||||||
resolve();
|
resolve();
|
||||||
reject();
|
reject();
|
||||||
|
@ -39,7 +39,9 @@ function Constructor(executor) {
|
|||||||
}
|
}
|
||||||
executor(resolve, $ERROR);
|
executor(resolve, $ERROR);
|
||||||
}
|
}
|
||||||
Constructor.resolve = function(v) { return v; };
|
Constructor.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
var p1OnFulfilled;
|
var p1OnFulfilled;
|
||||||
|
|
||||||
|
@ -39,7 +39,9 @@ function Constructor(executor) {
|
|||||||
}
|
}
|
||||||
executor(resolve, $ERROR);
|
executor(resolve, $ERROR);
|
||||||
}
|
}
|
||||||
Constructor.resolve = function(v) { return v; };
|
Constructor.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
var p1OnFulfilled;
|
var p1OnFulfilled;
|
||||||
|
|
||||||
|
@ -16,10 +16,13 @@ var thenable = {
|
|||||||
resolveElementFunction = fulfill;
|
resolveElementFunction = fulfill;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
NotPromise.resolve = function(v) { return v; };
|
NotPromise.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
Promise.all.call(NotPromise, [thenable]);
|
Promise.all.call(NotPromise, [thenable]);
|
||||||
|
|
||||||
assert(Object.isExtensible(resolveElementFunction));
|
assert(Object.isExtensible(resolveElementFunction));
|
||||||
|
@ -20,10 +20,13 @@ var thenable = {
|
|||||||
resolveElementFunction = fulfill;
|
resolveElementFunction = fulfill;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
NotPromise.resolve = function(v) { return v; };
|
NotPromise.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
Promise.all.call(NotPromise, [thenable]);
|
Promise.all.call(NotPromise, [thenable]);
|
||||||
|
|
||||||
assert.sameValue(resolveElementFunction.length, 1);
|
assert.sameValue(resolveElementFunction.length, 1);
|
||||||
|
@ -19,10 +19,13 @@ var thenable = {
|
|||||||
resolveElementFunction = fulfill;
|
resolveElementFunction = fulfill;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
NotPromise.resolve = function(v) { return v; };
|
NotPromise.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
Promise.all.call(NotPromise, [thenable]);
|
Promise.all.call(NotPromise, [thenable]);
|
||||||
|
|
||||||
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, "name"), false);
|
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, "name"), false);
|
||||||
|
@ -17,11 +17,16 @@ var thenable = {
|
|||||||
resolveElementFunction = fulfill;
|
resolveElementFunction = fulfill;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
NotPromise.resolve = function(v) { return v; };
|
NotPromise.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
Promise.all.call(NotPromise, [thenable]);
|
Promise.all.call(NotPromise, [thenable]);
|
||||||
|
|
||||||
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, "prototype"), false);
|
assert.sameValue(Object.prototype.hasOwnProperty.call(resolveElementFunction, "prototype"), false);
|
||||||
assert.throws(TypeError, function() { new resolveElementFunction(); });
|
assert.throws(TypeError, function() {
|
||||||
|
new resolveElementFunction();
|
||||||
|
});
|
||||||
|
@ -18,10 +18,13 @@ var thenable = {
|
|||||||
resolveElementFunction = fulfill;
|
resolveElementFunction = fulfill;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
NotPromise.resolve = function(v) { return v; };
|
NotPromise.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
Promise.all.call(NotPromise, [thenable]);
|
Promise.all.call(NotPromise, [thenable]);
|
||||||
|
|
||||||
assert.sameValue(Object.getPrototypeOf(resolveElementFunction), Function.prototype);
|
assert.sameValue(Object.getPrototypeOf(resolveElementFunction), Function.prototype);
|
||||||
|
@ -39,7 +39,9 @@ function Constructor(executor) {
|
|||||||
}
|
}
|
||||||
executor(resolve, $ERROR);
|
executor(resolve, $ERROR);
|
||||||
}
|
}
|
||||||
Constructor.resolve = function(v) { return v; };
|
Constructor.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
var p1OnFulfilled, p2OnFulfilled, p3OnFulfilled;
|
var p1OnFulfilled, p2OnFulfilled, p3OnFulfilled;
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ try {
|
|||||||
|
|
||||||
promise.then(function() {
|
promise.then(function() {
|
||||||
$DONE('The promise should not be fulfilled.');
|
$DONE('The promise should not be fulfilled.');
|
||||||
}, function(val) {
|
}, function(val) {
|
||||||
if (val !== value) {
|
if (val !== value) {
|
||||||
$DONE('The promise should be rejected with the expected value.');
|
$DONE('The promise should be rejected with the expected value.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$DONE();
|
$DONE();
|
||||||
});
|
});
|
||||||
|
@ -68,6 +68,6 @@ promise.then(function(val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$DONE();
|
$DONE();
|
||||||
}, function() {
|
}, function() {
|
||||||
$DONE('The promise should not be rejected.');
|
$DONE('The promise should not be rejected.');
|
||||||
});
|
});
|
||||||
|
@ -13,14 +13,17 @@ info: |
|
|||||||
...
|
...
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function rejectFunction() { }
|
function rejectFunction() {}
|
||||||
|
|
||||||
function Constructor(executor) {
|
function Constructor(executor) {
|
||||||
executor($ERROR, rejectFunction);
|
executor($ERROR, rejectFunction);
|
||||||
}
|
}
|
||||||
Constructor.resolve = function(v) { return v; };
|
Constructor.resolve = function(v) {
|
||||||
|
return v;
|
||||||
|
};
|
||||||
|
|
||||||
var callCount1 = 0, callCount2 = 0;
|
var callCount1 = 0,
|
||||||
|
callCount2 = 0;
|
||||||
|
|
||||||
var p1 = {
|
var p1 = {
|
||||||
then: function(onFulfilled, onRejected) {
|
then: function(onFulfilled, onRejected) {
|
||||||
|
@ -14,7 +14,7 @@ features: [Symbol.species]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
function C(executor) {
|
function C(executor) {
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
Object.defineProperty(C, Symbol.species, {
|
Object.defineProperty(C, Symbol.species, {
|
||||||
get: function() {
|
get: function() {
|
||||||
|
@ -11,9 +11,10 @@ info: |
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var executorFunction;
|
var executorFunction;
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executorFunction = executor;
|
executorFunction = executor;
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
Promise.resolve.call(NotPromise);
|
Promise.resolve.call(NotPromise);
|
||||||
|
|
||||||
|
@ -15,9 +15,10 @@ includes: [propertyHelper.js]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var executorFunction;
|
var executorFunction;
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executorFunction = executor;
|
executorFunction = executor;
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
Promise.resolve.call(NotPromise);
|
Promise.resolve.call(NotPromise);
|
||||||
|
|
||||||
|
@ -14,9 +14,10 @@ info: |
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var executorFunction;
|
var executorFunction;
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executorFunction = executor;
|
executorFunction = executor;
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
Promise.resolve.call(NotPromise);
|
Promise.resolve.call(NotPromise);
|
||||||
|
|
||||||
|
@ -12,11 +12,14 @@ info: |
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var executorFunction;
|
var executorFunction;
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executorFunction = executor;
|
executorFunction = executor;
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
Promise.resolve.call(NotPromise);
|
Promise.resolve.call(NotPromise);
|
||||||
|
|
||||||
assert.sameValue(Object.prototype.hasOwnProperty.call(executorFunction, "prototype"), false);
|
assert.sameValue(Object.prototype.hasOwnProperty.call(executorFunction, "prototype"), false);
|
||||||
assert.throws(TypeError, function() { new executorFunction(); });
|
assert.throws(TypeError, function() {
|
||||||
|
new executorFunction();
|
||||||
|
});
|
||||||
|
@ -13,9 +13,10 @@ info: |
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var executorFunction;
|
var executorFunction;
|
||||||
|
|
||||||
function NotPromise(executor) {
|
function NotPromise(executor) {
|
||||||
executorFunction = executor;
|
executorFunction = executor;
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
}
|
}
|
||||||
Promise.resolve.call(NotPromise);
|
Promise.resolve.call(NotPromise);
|
||||||
|
|
||||||
|
@ -12,4 +12,3 @@ description: Promise.prototype.constructor is the Promise constructor
|
|||||||
if (Promise.prototype.constructor !== Promise) {
|
if (Promise.prototype.constructor !== Promise) {
|
||||||
$ERROR("Expected Promise.prototype.constructor to be Promise");
|
$ERROR("Expected Promise.prototype.constructor to be Promise");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,11 +14,10 @@ var obj = {};
|
|||||||
|
|
||||||
var p = Promise.resolve(obj);
|
var p = Promise.resolve(obj);
|
||||||
|
|
||||||
p.catch(function () {
|
p.catch(function() {
|
||||||
$ERROR("Should not be called - promise is fulfilled");
|
$ERROR("Should not be called - promise is fulfilled");
|
||||||
}).then(function (arg) {
|
}).then(function(arg) {
|
||||||
if (arg !== obj) {
|
if (arg !== obj) {
|
||||||
$ERROR("Expected promise to be fulfilled with obj, got " + arg);
|
$ERROR("Expected promise to be fulfilled with obj, got " + arg);
|
||||||
}
|
}
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
|
||||||
|
@ -14,11 +14,10 @@ var obj = {};
|
|||||||
|
|
||||||
var p = Promise.reject(obj);
|
var p = Promise.reject(obj);
|
||||||
|
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
$ERROR("Should not be called: did not expect promise to be fulfilled");
|
$ERROR("Should not be called: did not expect promise to be fulfilled");
|
||||||
}).catch(function (arg) {
|
}).catch(function(arg) {
|
||||||
if (arg !== obj) {
|
if (arg !== obj) {
|
||||||
$ERROR("Should have been rejected with reason obj, got " + arg);
|
$ERROR("Should have been rejected with reason obj, got " + arg);
|
||||||
}
|
}
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
|
||||||
|
@ -24,21 +24,29 @@ features: [Symbol]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var booleanCount = 0;
|
var booleanCount = 0;
|
||||||
Boolean.prototype.then = function() { booleanCount += 1; };
|
Boolean.prototype.then = function() {
|
||||||
|
booleanCount += 1;
|
||||||
|
};
|
||||||
Promise.prototype.catch.call(true);
|
Promise.prototype.catch.call(true);
|
||||||
assert.sameValue(booleanCount, 1, 'boolean');
|
assert.sameValue(booleanCount, 1, 'boolean');
|
||||||
|
|
||||||
var numberCount = 0;
|
var numberCount = 0;
|
||||||
Number.prototype.then = function() { numberCount += 1; };
|
Number.prototype.then = function() {
|
||||||
|
numberCount += 1;
|
||||||
|
};
|
||||||
Promise.prototype.catch.call(34);
|
Promise.prototype.catch.call(34);
|
||||||
assert.sameValue(numberCount, 1, 'number');
|
assert.sameValue(numberCount, 1, 'number');
|
||||||
|
|
||||||
var stringCount = 0;
|
var stringCount = 0;
|
||||||
String.prototype.then = function() { stringCount += 1; };
|
String.prototype.then = function() {
|
||||||
|
stringCount += 1;
|
||||||
|
};
|
||||||
Promise.prototype.catch.call('');
|
Promise.prototype.catch.call('');
|
||||||
assert.sameValue(stringCount, 1, 'string');
|
assert.sameValue(stringCount, 1, 'string');
|
||||||
|
|
||||||
var symbolCount = 0;
|
var symbolCount = 0;
|
||||||
Symbol.prototype.then = function() { symbolCount += 1; };
|
Symbol.prototype.then = function() {
|
||||||
|
symbolCount += 1;
|
||||||
|
};
|
||||||
Promise.prototype.catch.call(Symbol());
|
Promise.prototype.catch.call(Symbol());
|
||||||
assert.sameValue(symbolCount, 1, 'symbol');
|
assert.sameValue(symbolCount, 1, 'symbol');
|
||||||
|
@ -38,25 +38,37 @@ assert.throws(TypeError, function() {
|
|||||||
}, 'undefined');
|
}, 'undefined');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.prototype.catch.call({ then: null });
|
Promise.prototype.catch.call({
|
||||||
|
then: null
|
||||||
|
});
|
||||||
}, 'null');
|
}, 'null');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.prototype.catch.call({ then: 1 });
|
Promise.prototype.catch.call({
|
||||||
|
then: 1
|
||||||
|
});
|
||||||
}, 'number');
|
}, 'number');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.prototype.catch.call({ then: '' });
|
Promise.prototype.catch.call({
|
||||||
|
then: ''
|
||||||
|
});
|
||||||
}, 'string');
|
}, 'string');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.prototype.catch.call({ then: true });
|
Promise.prototype.catch.call({
|
||||||
|
then: true
|
||||||
|
});
|
||||||
}, 'boolean');
|
}, 'boolean');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.prototype.catch.call({ then: symbol });
|
Promise.prototype.catch.call({
|
||||||
|
then: symbol
|
||||||
|
});
|
||||||
}, 'symbol');
|
}, 'symbol');
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.prototype.catch.call({ then: {} });
|
Promise.prototype.catch.call({
|
||||||
|
then: {}
|
||||||
|
});
|
||||||
}, 'ordinary object');
|
}, 'ordinary object');
|
||||||
|
@ -7,7 +7,7 @@ esid: sec-promise.prototype.finally
|
|||||||
features: [Promise.prototype.finally]
|
features: [Promise.prototype.finally]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var target = new Promise(function () {});
|
var target = new Promise(function() {});
|
||||||
var returnValue = {};
|
var returnValue = {};
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
var thisValue = null;
|
var thisValue = null;
|
||||||
@ -26,8 +26,8 @@ target.then = function(a, b) {
|
|||||||
return returnValue;
|
return returnValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
var originalFinallyHandler = function () {};
|
var originalFinallyHandler = function() {};
|
||||||
var anonName = Object(function () {}).name;
|
var anonName = Object(function() {}).name;
|
||||||
|
|
||||||
var result = Promise.prototype.finally.call(target, originalFinallyHandler, 2, 3);
|
var result = Promise.prototype.finally.call(target, originalFinallyHandler, 2, 3);
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ esid: sec-promise.prototype.finally
|
|||||||
features: [Promise.prototype.finally]
|
features: [Promise.prototype.finally]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var target = new Promise(function () {});
|
var target = new Promise(function() {});
|
||||||
var returnValue = {};
|
var returnValue = {};
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
var thisValue = null;
|
var thisValue = null;
|
||||||
|
@ -11,29 +11,29 @@ includes: [promiseHelper.js]
|
|||||||
var sequence = [];
|
var sequence = [];
|
||||||
var noReason = {};
|
var noReason = {};
|
||||||
var no = Promise.reject(noReason);
|
var no = Promise.reject(noReason);
|
||||||
no.then = function () {
|
no.then = function() {
|
||||||
sequence.push(1);
|
sequence.push(1);
|
||||||
return Promise.prototype.then.apply(this, arguments);
|
return Promise.prototype.then.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
var yesValue = {};
|
var yesValue = {};
|
||||||
var yes = Promise.resolve(yesValue);
|
var yes = Promise.resolve(yesValue);
|
||||||
yes.then = function () {
|
yes.then = function() {
|
||||||
sequence.push(4);
|
sequence.push(4);
|
||||||
return Promise.prototype.then.apply(this, arguments);
|
return Promise.prototype.then.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
no.catch(function (e) {
|
no.catch(function(e) {
|
||||||
sequence.push(2);
|
sequence.push(2);
|
||||||
assert.sameValue(e, noReason);
|
assert.sameValue(e, noReason);
|
||||||
throw e;
|
throw e;
|
||||||
}).finally(function () {
|
}).finally(function() {
|
||||||
sequence.push(3);
|
sequence.push(3);
|
||||||
return yes;
|
return yes;
|
||||||
}).catch(function (e) {
|
}).catch(function(e) {
|
||||||
sequence.push(5);
|
sequence.push(5);
|
||||||
assert.sameValue(e, noReason);
|
assert.sameValue(e, noReason);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
checkSequence(sequence, "All expected callbacks called in correct order");
|
checkSequence(sequence, "All expected callbacks called in correct order");
|
||||||
$DONE();
|
$DONE();
|
||||||
}).catch($ERROR);
|
}).catch($ERROR);
|
||||||
|
@ -14,13 +14,13 @@ var thrown = {};
|
|||||||
|
|
||||||
var p = Promise.reject(original);
|
var p = Promise.reject(original);
|
||||||
|
|
||||||
p.finally(function () {
|
p.finally(function() {
|
||||||
sequence.push(1);
|
sequence.push(1);
|
||||||
assert.sameValue(arguments.length, 0, 'onFinally receives zero args');
|
assert.sameValue(arguments.length, 0, 'onFinally receives zero args');
|
||||||
throw thrown;
|
throw thrown;
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
$ERROR('promise is rejected; onFulfill should not be called');
|
$ERROR('promise is rejected; onFulfill should not be called');
|
||||||
}).catch(function (reason) {
|
}).catch(function(reason) {
|
||||||
sequence.push(2);
|
sequence.push(2);
|
||||||
assert.sameValue(reason, thrown, 'onFinally can override the rejection reason by throwing');
|
assert.sameValue(reason, thrown, 'onFinally can override the rejection reason by throwing');
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
|
@ -12,11 +12,11 @@ var sequence = [];
|
|||||||
var obj = {};
|
var obj = {};
|
||||||
var p = Promise.resolve(obj);
|
var p = Promise.resolve(obj);
|
||||||
|
|
||||||
p.finally(function () {
|
p.finally(function() {
|
||||||
sequence.push(1);
|
sequence.push(1);
|
||||||
assert.sameValue(arguments.length, 0, 'onFinally receives zero args');
|
assert.sameValue(arguments.length, 0, 'onFinally receives zero args');
|
||||||
return {};
|
return {};
|
||||||
}).then(function (x) {
|
}).then(function(x) {
|
||||||
sequence.push(2);
|
sequence.push(2);
|
||||||
assert.sameValue(x, obj, 'onFinally can not override the resolution value');
|
assert.sameValue(x, obj, 'onFinally can not override the resolution value');
|
||||||
}).then(function() {
|
}).then(function() {
|
||||||
|
@ -11,30 +11,29 @@ includes: [promiseHelper.js]
|
|||||||
var sequence = [];
|
var sequence = [];
|
||||||
var yesValue = {};
|
var yesValue = {};
|
||||||
var yes = Promise.resolve(yesValue);
|
var yes = Promise.resolve(yesValue);
|
||||||
yes.then = function () {
|
yes.then = function() {
|
||||||
sequence.push(1);
|
sequence.push(1);
|
||||||
return Promise.prototype.then.apply(this, arguments);
|
return Promise.prototype.then.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
var noReason = {};
|
var noReason = {};
|
||||||
var no = Promise.reject(noReason);
|
var no = Promise.reject(noReason);
|
||||||
no.then = function () {
|
no.then = function() {
|
||||||
sequence.push(4);
|
sequence.push(4);
|
||||||
return Promise.prototype.then.apply(this, arguments);
|
return Promise.prototype.then.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
yes.then(function (x) {
|
yes.then(function(x) {
|
||||||
sequence.push(2);
|
sequence.push(2);
|
||||||
assert.sameValue(x, yesValue);
|
assert.sameValue(x, yesValue);
|
||||||
return x;
|
return x;
|
||||||
}).finally(function () {
|
}).finally(function() {
|
||||||
sequence.push(3);
|
sequence.push(3);
|
||||||
return no;
|
return no;
|
||||||
}).catch(function (e) {
|
}).catch(function(e) {
|
||||||
sequence.push(5);
|
sequence.push(5);
|
||||||
assert.sameValue(e, noReason);
|
assert.sameValue(e, noReason);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
checkSequence(sequence, "All expected callbacks called in correct order");
|
checkSequence(sequence, "All expected callbacks called in correct order");
|
||||||
$DONE();
|
$DONE();
|
||||||
}).catch($ERROR);
|
}).catch($ERROR);
|
||||||
|
|
||||||
|
@ -9,7 +9,9 @@ features: [Promise.prototype.finally]
|
|||||||
|
|
||||||
|
|
||||||
class MyPromise extends Promise {
|
class MyPromise extends Promise {
|
||||||
static get [Symbol.species]() { return Promise; }
|
static get[Symbol.species]() {
|
||||||
|
return Promise;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = Promise
|
var p = Promise
|
||||||
|
@ -8,7 +8,9 @@ features: [Promise.prototype.finally]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
class FooPromise extends Promise {
|
class FooPromise extends Promise {
|
||||||
static get [Symbol.species]() { return Promise; }
|
static get[Symbol.species]() {
|
||||||
|
return Promise;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = Promise.reject().finally(() => FooPromise.reject());
|
var p = Promise.reject().finally(() => FooPromise.reject());
|
||||||
|
@ -8,7 +8,9 @@ features: [Promise.prototype.finally]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
class FooPromise extends Promise {
|
class FooPromise extends Promise {
|
||||||
static get [Symbol.species]() { return Promise; }
|
static get[Symbol.species]() {
|
||||||
|
return Promise;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var p = Promise.resolve().finally(() => FooPromise.resolve());
|
var p = Promise.resolve().finally(() => FooPromise.resolve());
|
||||||
|
@ -11,7 +11,9 @@ features: [Promise.prototype.finally]
|
|||||||
var called = false;
|
var called = false;
|
||||||
var p = new Proxy(Promise.resolve(), {});
|
var p = new Proxy(Promise.resolve(), {});
|
||||||
var oldThen = Promise.prototype.then;
|
var oldThen = Promise.prototype.then;
|
||||||
Promise.prototype.then = () => { called = true; };
|
Promise.prototype.then = () => {
|
||||||
|
called = true;
|
||||||
|
};
|
||||||
Promise.prototype.finally.call(p);
|
Promise.prototype.finally.call(p);
|
||||||
assert.sameValue(called, true);
|
assert.sameValue(called, true);
|
||||||
Promise.prototype.then = oldThen;
|
Promise.prototype.then = oldThen;
|
||||||
|
@ -11,9 +11,11 @@ features: [Symbol, Promise.prototype.finally]
|
|||||||
|
|
||||||
var symbol = Symbol();
|
var symbol = Symbol();
|
||||||
|
|
||||||
var thrower = function () { throw new Test262Error('this should never happen'); };
|
var thrower = function() {
|
||||||
|
throw new Test262Error('this should never happen');
|
||||||
|
};
|
||||||
|
|
||||||
var p = new Promise(function () {});
|
var p = new Promise(function() {});
|
||||||
|
|
||||||
p.then = undefined;
|
p.then = undefined;
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
|
@ -9,7 +9,7 @@ esid: sec-promise.prototype.finally
|
|||||||
features: [Promise.prototype.finally]
|
features: [Promise.prototype.finally]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var poisonedThen = Object.defineProperty(new Promise(function () {}), 'then', {
|
var poisonedThen = Object.defineProperty(new Promise(function() {}), 'then', {
|
||||||
get: function() {
|
get: function() {
|
||||||
throw new Test262Error();
|
throw new Test262Error();
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ esid: sec-promise.prototype.finally
|
|||||||
features: [Promise.prototype.finally]
|
features: [Promise.prototype.finally]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var thrower = new Promise(function () {});
|
var thrower = new Promise(function() {});
|
||||||
thrower.then = function() {
|
thrower.then = function() {
|
||||||
throw new Test262Error();
|
throw new Test262Error();
|
||||||
};
|
};
|
||||||
|
@ -14,26 +14,26 @@ flags: [async]
|
|||||||
|
|
||||||
var sequence = [];
|
var sequence = [];
|
||||||
|
|
||||||
var p = new Promise(function(resolve, reject){
|
var p = new Promise(function(resolve, reject) {
|
||||||
sequence.push(1);
|
sequence.push(1);
|
||||||
resolve("");
|
resolve("");
|
||||||
});
|
});
|
||||||
|
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
sequence.push(3);
|
sequence.push(3);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
sequence.push(5);
|
sequence.push(5);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
sequence.push(7);
|
sequence.push(7);
|
||||||
});
|
});
|
||||||
|
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
sequence.push(4);
|
sequence.push(4);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
sequence.push(6);
|
sequence.push(6);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
sequence.push(8);
|
sequence.push(8);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
checkSequence(sequence, "Sequence should be as expected");
|
checkSequence(sequence, "Sequence should be as expected");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
|
||||||
|
@ -15,17 +15,17 @@ flags: [async]
|
|||||||
|
|
||||||
var resolveP1, rejectP2, sequence = [];
|
var resolveP1, rejectP2, sequence = [];
|
||||||
|
|
||||||
(new Promise(function (resolve, reject) {
|
(new Promise(function(resolve, reject) {
|
||||||
resolveP1 = resolve;
|
resolveP1 = resolve;
|
||||||
})).then(function (msg) {
|
})).then(function(msg) {
|
||||||
sequence.push(msg);
|
sequence.push(msg);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
checkSequence(sequence, "Expected 1,2,3");
|
checkSequence(sequence, "Expected 1,2,3");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
|
||||||
(new Promise(function (resolve, reject) {
|
(new Promise(function(resolve, reject) {
|
||||||
rejectP2 = reject;
|
rejectP2 = reject;
|
||||||
})).catch(function (msg) {
|
})).catch(function(msg) {
|
||||||
sequence.push(msg);
|
sequence.push(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -16,23 +16,23 @@ flags: [async]
|
|||||||
var resolveP1, rejectP2, p1, p2,
|
var resolveP1, rejectP2, p1, p2,
|
||||||
sequence = [];
|
sequence = [];
|
||||||
|
|
||||||
p1 = new Promise(function (resolve, reject) {
|
p1 = new Promise(function(resolve, reject) {
|
||||||
resolveP1 = resolve;
|
resolveP1 = resolve;
|
||||||
});
|
});
|
||||||
p2 = new Promise(function (resolve, reject) {
|
p2 = new Promise(function(resolve, reject) {
|
||||||
rejectP2 = reject;
|
rejectP2 = reject;
|
||||||
});
|
});
|
||||||
|
|
||||||
rejectP2(3);
|
rejectP2(3);
|
||||||
resolveP1(2);
|
resolveP1(2);
|
||||||
|
|
||||||
p1.then(function (msg) {
|
p1.then(function(msg) {
|
||||||
sequence.push(msg);
|
sequence.push(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
p2.catch(function (msg) {
|
p2.catch(function(msg) {
|
||||||
sequence.push(msg);
|
sequence.push(msg);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
checkSequence(sequence, "Expected 1,2,3");
|
checkSequence(sequence, "Expected 1,2,3");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
|
||||||
|
@ -16,28 +16,26 @@ flags: [async]
|
|||||||
var resolveP1, rejectP2, p1, p2,
|
var resolveP1, rejectP2, p1, p2,
|
||||||
sequence = [];
|
sequence = [];
|
||||||
|
|
||||||
p1 = new Promise(function (resolve, reject) {
|
p1 = new Promise(function(resolve, reject) {
|
||||||
resolveP1 = resolve;
|
resolveP1 = resolve;
|
||||||
});
|
});
|
||||||
p2 = new Promise(function (resolve, reject) {
|
p2 = new Promise(function(resolve, reject) {
|
||||||
rejectP2 = reject;
|
rejectP2 = reject;
|
||||||
});
|
});
|
||||||
|
|
||||||
rejectP2(3);
|
rejectP2(3);
|
||||||
resolveP1(2);
|
resolveP1(2);
|
||||||
|
|
||||||
Promise.resolve().then(function () {
|
Promise.resolve().then(function() {
|
||||||
p1.then(function (msg) {
|
p1.then(function(msg) {
|
||||||
sequence.push(msg);
|
sequence.push(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
p2.catch(function (msg) {
|
p2.catch(function(msg) {
|
||||||
sequence.push(msg);
|
sequence.push(msg);
|
||||||
}).then(function () {
|
}).then(function() {
|
||||||
checkSequence(sequence, "Expected 1,2,3");
|
checkSequence(sequence, "Expected 1,2,3");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
});
|
});
|
||||||
|
|
||||||
sequence.push(1);
|
sequence.push(1);
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ author: Sam Mikes
|
|||||||
description: Promise.prototype.then is a function of two arguments
|
description: Promise.prototype.then is a function of two arguments
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var p = new Promise(function () {});
|
var p = new Promise(function() {});
|
||||||
|
|
||||||
if (!(p.then instanceof Function)) {
|
if (!(p.then instanceof Function)) {
|
||||||
$ERROR("Expected p.then to be a function");
|
$ERROR("Expected p.then to be a function");
|
||||||
@ -18,5 +18,3 @@ if (!(p.then instanceof Function)) {
|
|||||||
if (p.then.length !== 2) {
|
if (p.then.length !== 2) {
|
||||||
$ERROR("Expected p.then to be a function of two arguments");
|
$ERROR("Expected p.then to be a function of two arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ author: Sam Mikes
|
|||||||
description: Promise.prototype.then throw if 'this' is non-Object
|
description: Promise.prototype.then throw if 'this' is non-Object
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var p = new Promise(function () {});
|
var p = new Promise(function() {});
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
p.then.call(3, function () {}, function () {});
|
p.then.call(3, function() {}, function() {});
|
||||||
});
|
});
|
||||||
|
@ -9,11 +9,10 @@ author: Sam Mikes
|
|||||||
description: Promise.prototype.then throw if 'this' is non-Promise Object
|
description: Promise.prototype.then throw if 'this' is non-Promise Object
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
function ZeroArgConstructor() {
|
function ZeroArgConstructor() {}
|
||||||
}
|
|
||||||
|
|
||||||
var z = new ZeroArgConstructor();
|
var z = new ZeroArgConstructor();
|
||||||
|
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Promise.then.call(z, function () {}, function () {});
|
Promise.then.call(z, function() {}, function() {});
|
||||||
});
|
});
|
||||||
|
@ -15,7 +15,7 @@ var obj = {};
|
|||||||
var p = Promise.resolve(obj);
|
var p = Promise.resolve(obj);
|
||||||
|
|
||||||
p.then(undefined, undefined)
|
p.then(undefined, undefined)
|
||||||
.then(function (arg) {
|
.then(function(arg) {
|
||||||
if (arg !== obj) {
|
if (arg !== obj) {
|
||||||
$ERROR("Expected resolution object to be passed through, got " + arg);
|
$ERROR("Expected resolution object to be passed through, got " + arg);
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,10 @@ flags: [async]
|
|||||||
var obj = {};
|
var obj = {};
|
||||||
var p = Promise.reject(obj);
|
var p = Promise.reject(obj);
|
||||||
|
|
||||||
p.then(undefined, undefined).then(function () {
|
p.then(undefined, undefined).then(function() {
|
||||||
$ERROR("Should not be called -- promise was rejected.");
|
$ERROR("Should not be called -- promise was rejected.");
|
||||||
}, function (arg) {
|
}, function(arg) {
|
||||||
if (arg !== obj) {
|
if (arg !== obj) {
|
||||||
$ERROR("Expected resolution object to be passed through, got " + arg);
|
$ERROR("Expected resolution object to be passed through, got " + arg);
|
||||||
}
|
}
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -15,7 +15,7 @@ var obj = {};
|
|||||||
var p = Promise.resolve(obj);
|
var p = Promise.resolve(obj);
|
||||||
|
|
||||||
p.then(3, 5)
|
p.then(3, 5)
|
||||||
.then(function (arg) {
|
.then(function(arg) {
|
||||||
if (arg !== obj) {
|
if (arg !== obj) {
|
||||||
$ERROR("Expected resolution object to be passed through, got " + arg);
|
$ERROR("Expected resolution object to be passed through, got " + arg);
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ flags: [async]
|
|||||||
var obj = {};
|
var obj = {};
|
||||||
var p = Promise.reject(obj);
|
var p = Promise.reject(obj);
|
||||||
|
|
||||||
p.then(3, 5).then(function () {
|
p.then(3, 5).then(function() {
|
||||||
$ERROR("Should not be called -- promise was rejected.");
|
$ERROR("Should not be called -- promise was rejected.");
|
||||||
}, function (arg) {
|
}, function(arg) {
|
||||||
if (arg !== obj) {
|
if (arg !== obj) {
|
||||||
$ERROR("Expected resolution object to be passed through, got " + arg);
|
$ERROR("Expected resolution object to be passed through, got " + arg);
|
||||||
}
|
}
|
||||||
|
@ -14,20 +14,20 @@ flags: [async]
|
|||||||
|
|
||||||
var sequence = [],
|
var sequence = [],
|
||||||
pResolve,
|
pResolve,
|
||||||
p = new Promise(function (resolve, reject) {
|
p = new Promise(function(resolve, reject) {
|
||||||
pResolve = resolve;
|
pResolve = resolve;
|
||||||
});
|
});
|
||||||
|
|
||||||
sequence.push(1);
|
sequence.push(1);
|
||||||
|
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
sequence.push(3);
|
sequence.push(3);
|
||||||
checkSequence(sequence, "Should be second");
|
checkSequence(sequence, "Should be second");
|
||||||
}).catch($DONE);
|
}).catch($DONE);
|
||||||
|
|
||||||
Promise.resolve().then(function () {
|
Promise.resolve().then(function() {
|
||||||
// enqueue another then-handler
|
// enqueue another then-handler
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
sequence.push(4);
|
sequence.push(4);
|
||||||
checkSequence(sequence, "Should be third");
|
checkSequence(sequence, "Should be third");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -14,7 +14,7 @@ flags: [async]
|
|||||||
|
|
||||||
var sequence = [],
|
var sequence = [],
|
||||||
pResolve,
|
pResolve,
|
||||||
p = new Promise(function (resolve, reject) {
|
p = new Promise(function(resolve, reject) {
|
||||||
pResolve = resolve;
|
pResolve = resolve;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -22,14 +22,14 @@ sequence.push(1);
|
|||||||
|
|
||||||
pResolve();
|
pResolve();
|
||||||
|
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
sequence.push(3);
|
sequence.push(3);
|
||||||
checkSequence(sequence, "Should be first");
|
checkSequence(sequence, "Should be first");
|
||||||
}).catch($DONE);
|
}).catch($DONE);
|
||||||
|
|
||||||
Promise.resolve().then(function () {
|
Promise.resolve().then(function() {
|
||||||
// enqueue another then-handler
|
// enqueue another then-handler
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
sequence.push(5);
|
sequence.push(5);
|
||||||
checkSequence(sequence, "Should be third");
|
checkSequence(sequence, "Should be third");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -14,7 +14,7 @@ flags: [async]
|
|||||||
|
|
||||||
var sequence = [],
|
var sequence = [],
|
||||||
pReject,
|
pReject,
|
||||||
p = new Promise(function (resolve, reject) {
|
p = new Promise(function(resolve, reject) {
|
||||||
pReject = reject;
|
pReject = reject;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -22,18 +22,18 @@ sequence.push(1);
|
|||||||
|
|
||||||
pReject();
|
pReject();
|
||||||
|
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
$ERROR("Should not be called -- Promise rejected.");
|
$ERROR("Should not be called -- Promise rejected.");
|
||||||
}, function () {
|
}, function() {
|
||||||
sequence.push(3);
|
sequence.push(3);
|
||||||
checkSequence(sequence, "Should be first");
|
checkSequence(sequence, "Should be first");
|
||||||
}).catch($DONE);
|
}).catch($DONE);
|
||||||
|
|
||||||
Promise.resolve().then(function () {
|
Promise.resolve().then(function() {
|
||||||
// enqueue another then-handler
|
// enqueue another then-handler
|
||||||
p.then(function () {
|
p.then(function() {
|
||||||
$ERROR("Should not be called (2) -- Promise rejected.");
|
$ERROR("Should not be called (2) -- Promise rejected.");
|
||||||
}, function () {
|
}, function() {
|
||||||
sequence.push(5);
|
sequence.push(5);
|
||||||
checkSequence(sequence, "Should be third");
|
checkSequence(sequence, "Should be third");
|
||||||
}).then($DONE, $DONE);
|
}).then($DONE, $DONE);
|
||||||
|
@ -33,14 +33,14 @@ var promise = new class extends Promise {
|
|||||||
}
|
}
|
||||||
return super(executor);
|
return super(executor);
|
||||||
}
|
}
|
||||||
}(function(){});
|
}(function() {});
|
||||||
|
|
||||||
var checkPoint = "";
|
var checkPoint = "";
|
||||||
constructorFunction = function(executor) {
|
constructorFunction = function(executor) {
|
||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor();
|
executor();
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
};
|
};
|
||||||
promise.then();
|
promise.then();
|
||||||
@ -51,7 +51,7 @@ constructorFunction = function(executor) {
|
|||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(undefined, undefined);
|
executor(undefined, undefined);
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
};
|
};
|
||||||
promise.then();
|
promise.then();
|
||||||
@ -61,9 +61,9 @@ var checkPoint = "";
|
|||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
constructorFunction = function(executor) {
|
constructorFunction = function(executor) {
|
||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(undefined, function(){});
|
executor(undefined, function() {});
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
};
|
};
|
||||||
promise.then();
|
promise.then();
|
||||||
@ -74,9 +74,9 @@ var checkPoint = "";
|
|||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
constructorFunction = function(executor) {
|
constructorFunction = function(executor) {
|
||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(function(){}, undefined);
|
executor(function() {}, undefined);
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
};
|
};
|
||||||
promise.then();
|
promise.then();
|
||||||
@ -89,7 +89,7 @@ assert.throws(TypeError, function() {
|
|||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor("invalid value", 123);
|
executor("invalid value", 123);
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
executor(function(){}, function(){});
|
executor(function() {}, function() {});
|
||||||
checkPoint += "c";
|
checkPoint += "c";
|
||||||
};
|
};
|
||||||
promise.then();
|
promise.then();
|
||||||
|
@ -35,7 +35,7 @@ var promise = new class extends Promise {
|
|||||||
}
|
}
|
||||||
return super(executor);
|
return super(executor);
|
||||||
}
|
}
|
||||||
}(function(){});
|
}(function() {});
|
||||||
|
|
||||||
var checkPoint = "";
|
var checkPoint = "";
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
@ -72,7 +72,7 @@ var checkPoint = "";
|
|||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
constructorFunction = function(executor) {
|
constructorFunction = function(executor) {
|
||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(undefined, function(){});
|
executor(undefined, function() {});
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
};
|
};
|
||||||
promise.then();
|
promise.then();
|
||||||
@ -83,7 +83,7 @@ var checkPoint = "";
|
|||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
constructorFunction = function(executor) {
|
constructorFunction = function(executor) {
|
||||||
checkPoint += "a";
|
checkPoint += "a";
|
||||||
executor(function(){}, undefined);
|
executor(function() {}, undefined);
|
||||||
checkPoint += "b";
|
checkPoint += "b";
|
||||||
};
|
};
|
||||||
promise.then();
|
promise.then();
|
||||||
|
@ -29,7 +29,9 @@ flags: [async]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var callCount = 0;
|
var callCount = 0;
|
||||||
var prms = new Promise(function(resolve) { resolve(); });
|
var prms = new Promise(function(resolve) {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
Object.defineProperty(prms, 'constructor', {
|
Object.defineProperty(prms, 'constructor', {
|
||||||
get: function() {
|
get: function() {
|
||||||
callCount += 1;
|
callCount += 1;
|
||||||
@ -44,6 +46,6 @@ prms.then(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$DONE();
|
$DONE();
|
||||||
}, function() {
|
}, function() {
|
||||||
$DONE('The promise should not be rejected.');
|
$DONE('The promise should not be rejected.');
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@ description: Promise.prototype.then throws if Get(promise, "constructor") throws
|
|||||||
var p = Promise.resolve("foo");
|
var p = Promise.resolve("foo");
|
||||||
|
|
||||||
Object.defineProperty(p, "constructor", {
|
Object.defineProperty(p, "constructor", {
|
||||||
get: function () {
|
get: function() {
|
||||||
throw new Test262Error();
|
throw new Test262Error();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -26,10 +26,14 @@ var BadCtor = function() {
|
|||||||
};
|
};
|
||||||
var originalSpecies = Object.getOwnPropertyDescriptor(Promise, Symbol.species);
|
var originalSpecies = Object.getOwnPropertyDescriptor(Promise, Symbol.species);
|
||||||
|
|
||||||
Object.defineProperty(Promise, Symbol.species, { value: BadCtor });
|
Object.defineProperty(Promise, Symbol.species, {
|
||||||
|
value: BadCtor
|
||||||
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var p = new Promise(function(resolve) { resolve(); });
|
var p = new Promise(function(resolve) {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
|
||||||
assert.throws(Test262Error, function() {
|
assert.throws(Test262Error, function() {
|
||||||
p.then();
|
p.then();
|
||||||
|
@ -20,7 +20,9 @@ flags: [async]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var value = {};
|
var value = {};
|
||||||
var p = new Promise(function(resolve) { resolve(value); });
|
var p = new Promise(function(resolve) {
|
||||||
|
resolve(value);
|
||||||
|
});
|
||||||
|
|
||||||
p.then(function(x) {
|
p.then(function(x) {
|
||||||
if (x !== value) {
|
if (x !== value) {
|
||||||
@ -28,6 +30,6 @@ p.then(function(x) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$DONE();
|
$DONE();
|
||||||
}, function() {
|
}, function() {
|
||||||
$DONE('The `onRejected` handler should not be invoked.');
|
$DONE('The `onRejected` handler should not be invoked.');
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,9 @@ flags: [async]
|
|||||||
|
|
||||||
var value = {};
|
var value = {};
|
||||||
var resolve;
|
var resolve;
|
||||||
var p = new Promise(function(_resolve) { resolve = _resolve; });
|
var p = new Promise(function(_resolve) {
|
||||||
|
resolve = _resolve;
|
||||||
|
});
|
||||||
|
|
||||||
p.then(function(x) {
|
p.then(function(x) {
|
||||||
if (x !== value) {
|
if (x !== value) {
|
||||||
@ -29,8 +31,8 @@ p.then(function(x) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$DONE();
|
$DONE();
|
||||||
}, function() {
|
}, function() {
|
||||||
$DONE('The `onRejected` handler should not be invoked.');
|
$DONE('The `onRejected` handler should not be invoked.');
|
||||||
});
|
});
|
||||||
|
|
||||||
resolve(value);
|
resolve(value);
|
||||||
|
@ -21,16 +21,18 @@ flags: [async]
|
|||||||
|
|
||||||
var value = {};
|
var value = {};
|
||||||
var reject;
|
var reject;
|
||||||
var p = new Promise(function(_, _reject) { reject = _reject; });
|
var p = new Promise(function(_, _reject) {
|
||||||
|
reject = _reject;
|
||||||
|
});
|
||||||
|
|
||||||
p.then(function() {
|
p.then(function() {
|
||||||
$DONE('The `onFulfilled` handler should not be invoked.');
|
$DONE('The `onFulfilled` handler should not be invoked.');
|
||||||
}, function(x) {
|
}, function(x) {
|
||||||
if (x !== value) {
|
if (x !== value) {
|
||||||
$DONE('The `onRejected` handler should be invoked with the promise result.');
|
$DONE('The `onRejected` handler should be invoked with the promise result.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$DONE();
|
$DONE();
|
||||||
});
|
});
|
||||||
|
|
||||||
reject(value);
|
reject(value);
|
||||||
|
@ -20,14 +20,16 @@ flags: [async]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var value = {};
|
var value = {};
|
||||||
var p = new Promise(function(_, reject) { reject(value); });
|
var p = new Promise(function(_, reject) {
|
||||||
|
reject(value);
|
||||||
|
});
|
||||||
|
|
||||||
p.then(function() {
|
p.then(function() {
|
||||||
$DONE('The `onFulfilled` handler should not be invoked.');
|
$DONE('The `onFulfilled` handler should not be invoked.');
|
||||||
}, function(x) {
|
}, function(x) {
|
||||||
if (x !== value) {
|
if (x !== value) {
|
||||||
$DONE('The `onRejected` handler should be invoked with the promise result.');
|
$DONE('The `onRejected` handler should be invoked with the promise result.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$DONE();
|
$DONE();
|
||||||
});
|
});
|
||||||
|
@ -22,23 +22,27 @@ flags: [async]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var resolve;
|
var resolve;
|
||||||
var thenable = new Promise(function(_resolve) { resolve = _resolve; });
|
var thenable = new Promise(function(_resolve) {
|
||||||
var p1 = new Promise(function(resolve) { resolve(); });
|
resolve = _resolve;
|
||||||
|
});
|
||||||
|
var p1 = new Promise(function(resolve) {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
var p2;
|
var p2;
|
||||||
|
|
||||||
p2 = p1.then(function() {
|
p2 = p1.then(function() {
|
||||||
throw thenable;
|
throw thenable;
|
||||||
});
|
});
|
||||||
|
|
||||||
p2.then(function() {
|
p2.then(function() {
|
||||||
$DONE('The promise should not be fulfilled.');
|
$DONE('The promise should not be fulfilled.');
|
||||||
}, function(x) {
|
}, function(x) {
|
||||||
if (x !== thenable) {
|
if (x !== thenable) {
|
||||||
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$DONE();
|
$DONE();
|
||||||
});
|
});
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -23,23 +23,27 @@ flags: [async]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var reject;
|
var reject;
|
||||||
var thenable = new Promise(function(resolve) { resolve(); });
|
var thenable = new Promise(function(resolve) {
|
||||||
var p1 = new Promise(function(_, _reject) { reject = _reject; });
|
resolve();
|
||||||
|
});
|
||||||
|
var p1 = new Promise(function(_, _reject) {
|
||||||
|
reject = _reject;
|
||||||
|
});
|
||||||
var p2;
|
var p2;
|
||||||
|
|
||||||
p2 = p1.then(function() {}, function() {
|
p2 = p1.then(function() {}, function() {
|
||||||
throw thenable;
|
throw thenable;
|
||||||
});
|
});
|
||||||
|
|
||||||
p2.then(function() {
|
p2.then(function() {
|
||||||
$DONE('The promise should not be fulfilled.');
|
$DONE('The promise should not be fulfilled.');
|
||||||
}, function(x) {
|
}, function(x) {
|
||||||
if (x !== thenable) {
|
if (x !== thenable) {
|
||||||
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$DONE();
|
$DONE();
|
||||||
});
|
});
|
||||||
|
|
||||||
reject();
|
reject();
|
||||||
|
@ -29,21 +29,25 @@ info: |
|
|||||||
flags: [async]
|
flags: [async]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var thenable = new Promise(function(resolve) { resolve(); });
|
var thenable = new Promise(function(resolve) {
|
||||||
var p1 = new Promise(function(resolve) { resolve(); });
|
resolve();
|
||||||
|
});
|
||||||
|
var p1 = new Promise(function(resolve) {
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
var p2;
|
var p2;
|
||||||
|
|
||||||
p2 = p1.then(function() {
|
p2 = p1.then(function() {
|
||||||
throw thenable;
|
throw thenable;
|
||||||
});
|
});
|
||||||
|
|
||||||
p2.then(function() {
|
p2.then(function() {
|
||||||
$DONE('The promise should not be fulfilled.');
|
$DONE('The promise should not be fulfilled.');
|
||||||
}, function(x) {
|
}, function(x) {
|
||||||
if (x !== thenable) {
|
if (x !== thenable) {
|
||||||
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$DONE();
|
$DONE();
|
||||||
});
|
});
|
||||||
|
@ -29,21 +29,25 @@ info: |
|
|||||||
flags: [async]
|
flags: [async]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
var thenable = new Promise(function(resolve) { resolve(); });
|
var thenable = new Promise(function(resolve) {
|
||||||
var p1 = new Promise(function(_, reject) { reject(); });
|
resolve();
|
||||||
|
});
|
||||||
|
var p1 = new Promise(function(_, reject) {
|
||||||
|
reject();
|
||||||
|
});
|
||||||
var p2;
|
var p2;
|
||||||
|
|
||||||
p2 = p1.then(function() {}, function() {
|
p2 = p1.then(function() {}, function() {
|
||||||
throw thenable;
|
throw thenable;
|
||||||
});
|
});
|
||||||
|
|
||||||
p2.then(function() {
|
p2.then(function() {
|
||||||
$DONE('The promise should not be fulfilled.');
|
$DONE('The promise should not be fulfilled.');
|
||||||
}, function(x) {
|
}, function(x) {
|
||||||
if (x !== thenable) {
|
if (x !== thenable) {
|
||||||
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
$DONE('The promise should be rejected with the resolution value of the provided promise.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$DONE();
|
$DONE();
|
||||||
});
|
});
|
||||||
|
@ -22,12 +22,14 @@ flags: [async]
|
|||||||
---*/
|
---*/
|
||||||
|
|
||||||
var resolve;
|
var resolve;
|
||||||
var p1 = new Promise(function(_resolve) { resolve = _resolve; });
|
var p1 = new Promise(function(_resolve) {
|
||||||
|
resolve = _resolve;
|
||||||
|
});
|
||||||
var p2;
|
var p2;
|
||||||
|
|
||||||
p2 = p1.then(function() {
|
p2 = p1.then(function() {
|
||||||
return 23;
|
return 23;
|
||||||
});
|
});
|
||||||
|
|
||||||
p2.then(function(value) {
|
p2.then(function(value) {
|
||||||
if (value !== 23) {
|
if (value !== 23) {
|
||||||
@ -36,8 +38,8 @@ p2.then(function(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$DONE();
|
$DONE();
|
||||||
}, function() {
|
}, function() {
|
||||||
$DONE('The promise should not be rejected.');
|
$DONE('The promise should not be rejected.');
|
||||||
});
|
});
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user