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