mirror of https://github.com/tc39/test262.git
chore: migrate $ERROR -> throw new Test262Error in test/built-ins/Promise (#3091)
This commit is contained in:
parent
6230065d07
commit
826b6ae16f
|
@ -9,5 +9,5 @@ description: Promise.all is callable
|
|||
---*/
|
||||
|
||||
if ((typeof Promise.all) !== "function") {
|
||||
$ERROR('Expected Promise.all to be a function');
|
||||
throw new Test262Error('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');
|
||||
throw new Test262Error('Expected p to be a Promise');
|
||||
}
|
||||
|
|
|
@ -13,6 +13,6 @@ var arg = [];
|
|||
|
||||
Promise.all(arg).then(function(result) {
|
||||
if (!(result instanceof Array)) {
|
||||
$ERROR("expected an array from Promise.all, got " + result);
|
||||
throw new Test262Error("expected an array from Promise.all, got " + result);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -13,6 +13,6 @@ var arg = [];
|
|||
|
||||
Promise.all(arg).then(function(result) {
|
||||
if (result.length !== 0) {
|
||||
$ERROR("expected an empty array from Promise.all([]), got " + result);
|
||||
throw new Test262Error("expected an empty array from Promise.all([]), got " + result);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -13,6 +13,6 @@ var arg = [];
|
|||
|
||||
Promise.all(arg).then(function(result) {
|
||||
if (result === arg) {
|
||||
$ERROR("expected a new array from Promise.all but argument was re-used");
|
||||
throw new Test262Error("expected a new array from Promise.all but argument was re-used");
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -15,9 +15,9 @@ flags: [async]
|
|||
var nonIterable = 3;
|
||||
|
||||
Promise.all(nonIterable).then(function() {
|
||||
$ERROR('Promise unexpectedly resolved: Promise.all(nonIterable) should throw TypeError');
|
||||
throw new Test262Error('Promise unexpectedly resolved: Promise.all(nonIterable) should throw TypeError');
|
||||
}, function(err) {
|
||||
if (!(err instanceof TypeError)) {
|
||||
$ERROR('Expected TypeError, got ' + err);
|
||||
throw new Test262Error('Expected TypeError, got ' + err);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -14,9 +14,9 @@ flags: [async]
|
|||
---*/
|
||||
|
||||
Promise.all(new Error("abrupt")).then(function() {
|
||||
$ERROR('Promise unexpectedly resolved: Promise.all(abruptCompletion) should throw TypeError');
|
||||
throw new Test262Error('Promise unexpectedly resolved: Promise.all(abruptCompletion) should throw TypeError');
|
||||
}, function(err) {
|
||||
if (!(err instanceof TypeError)) {
|
||||
$ERROR('Expected TypeError, got ' + err);
|
||||
throw new Test262Error('Expected TypeError, got ' + err);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -20,9 +20,9 @@ Object.defineProperty(iterThrows, Symbol.iterator, {
|
|||
});
|
||||
|
||||
Promise.all(iterThrows).then(function() {
|
||||
$ERROR('Promise unexpectedly fulfilled: Promise.all(iterThrows) should throw TypeError');
|
||||
throw new Test262Error('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);
|
||||
throw new Test262Error('Expected promise to be rejected with error, got ' + err);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -23,7 +23,7 @@ iterThrows[Symbol.iterator] = function() {
|
|||
};
|
||||
|
||||
Promise.all(iterThrows).then(function() {
|
||||
$ERROR('Promise unexpectedly resolved: Promise.all(iterThrows) should throw TypeError');
|
||||
throw new Test262Error('Promise unexpectedly resolved: Promise.all(iterThrows) should throw TypeError');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -17,15 +17,15 @@ var pAll = Promise.all([p1]);
|
|||
|
||||
pAll.then(function(result) {
|
||||
if (!(pAll instanceof Promise)) {
|
||||
$ERROR("Expected Promise.all() to be promise, actually " + pAll);
|
||||
throw new Test262Error("Expected Promise.all() to be promise, actually " + pAll);
|
||||
}
|
||||
if (!(result instanceof Array)) {
|
||||
$ERROR("Expected Promise.all() to be promise for an Array, actually " + result);
|
||||
throw new Test262Error("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);
|
||||
throw new Test262Error("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]);
|
||||
throw new Test262Error("Expected result[0] to be 3, actually " + result[0]);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -17,10 +17,10 @@ var rejectP1,
|
|||
p2 = Promise.resolve(2);
|
||||
|
||||
Promise.all([p1, p2]).then(function(resolve) {
|
||||
$ERROR("Did not expect promise to be fulfilled.");
|
||||
throw new Test262Error("Did not expect promise to be fulfilled.");
|
||||
}, function(rejected) {
|
||||
if (rejected !== 1) {
|
||||
$ERROR("Expected promise to be rejected with 1, actually " + rejected);
|
||||
throw new Test262Error("Expected promise to be rejected with 1, actually " + rejected);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@ var rejectP2,
|
|||
});
|
||||
|
||||
Promise.all([p1, p2]).then(function() {
|
||||
$ERROR("Did not expect promise to be fulfilled.");
|
||||
throw new Test262Error("Did not expect promise to be fulfilled.");
|
||||
}, function(rejected) {
|
||||
if (rejected !== 2) {
|
||||
$ERROR("Expected promise to be rejected with 2, actually " + rejected);
|
||||
throw new Test262Error("Expected promise to be rejected with 2, actually " + rejected);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ flags: [async]
|
|||
|
||||
Object.defineProperty(Array.prototype, 0, {
|
||||
set: function() {
|
||||
$ERROR("Setter on Array.prototype called");
|
||||
throw new Test262Error("Setter on Array.prototype called");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ Promise.resolve = function() {
|
|||
|
||||
Promise.all([1])
|
||||
.then(function() {
|
||||
$ERROR('The promise should not be fulfilled.');
|
||||
throw new Test262Error('The promise should not be fulfilled.');
|
||||
}, function(reason) {
|
||||
if (reason !== thrown) {
|
||||
$ERROR('The promise should be rejected with the thrown error object');
|
||||
throw new Test262Error('The promise should be rejected with the thrown error object');
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -34,7 +34,7 @@ Object.defineProperty(Promise, 'resolve', {
|
|||
});
|
||||
|
||||
Promise.all([new Promise(function() {})]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
throw new Test262Error('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -33,7 +33,7 @@ promise.then = function() {
|
|||
};
|
||||
|
||||
Promise.all([promise]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
throw new Test262Error('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -34,7 +34,7 @@ Object.defineProperty(promise, 'then', {
|
|||
});
|
||||
|
||||
Promise.all([promise]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
throw new Test262Error('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -36,7 +36,7 @@ Object.defineProperty(poisonedDone, 'done', {
|
|||
});
|
||||
Object.defineProperty(poisonedDone, 'value', {
|
||||
get: function() {
|
||||
$ERROR('The `value` property should not be accessed.');
|
||||
throw new Test262Error('The `value` property should not be accessed.');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ function C(executor) {
|
|||
C.resolve = function() {};
|
||||
Object.defineProperty(C, Symbol.species, {
|
||||
get: function() {
|
||||
$ERROR("Getter for Symbol.species called");
|
||||
throw new Test262Error("Getter for Symbol.species called");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -26,9 +26,9 @@ Promise.resolve = function() {
|
|||
|
||||
Promise.allSettled([1])
|
||||
.then(function() {
|
||||
$ERROR('The promise should not be fulfilled.');
|
||||
throw new Test262Error('The promise should not be fulfilled.');
|
||||
}, function(reason) {
|
||||
if (reason !== thrown) {
|
||||
$ERROR('The promise should be rejected with the thrown error object');
|
||||
throw new Test262Error('The promise should be rejected with the thrown error object');
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -28,7 +28,7 @@ Object.defineProperty(Promise, 'resolve', {
|
|||
});
|
||||
|
||||
Promise.allSettled([new Promise(function() {})]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
throw new Test262Error('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -27,7 +27,7 @@ Object.defineProperty(promise, 'then', {
|
|||
});
|
||||
|
||||
Promise.allSettled([promise]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
throw new Test262Error('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -48,7 +48,7 @@ function P(executor) {
|
|||
callCount++;
|
||||
executor(() => {
|
||||
callCount++;
|
||||
$ERROR();
|
||||
throw new Test262Error();
|
||||
}, () => {
|
||||
callCount++;
|
||||
reject(new Test262Error('reject throws'));
|
||||
|
|
|
@ -11,5 +11,5 @@ description: Promise prototype exists
|
|||
---*/
|
||||
|
||||
if (Promise.prototype === undefined) {
|
||||
$ERROR("Expected Promise.prototype to be defined.");
|
||||
throw new Test262Error("Expected Promise.prototype to be defined.");
|
||||
}
|
||||
|
|
|
@ -10,5 +10,5 @@ description: Promise.prototype.constructor is the Promise constructor
|
|||
---*/
|
||||
|
||||
if (Promise.prototype.constructor !== Promise) {
|
||||
$ERROR("Expected Promise.prototype.constructor to be Promise");
|
||||
throw new Test262Error("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");
|
||||
throw new Test262Error("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");
|
||||
throw new Test262Error("Expected p.catch to be a function");
|
||||
}
|
||||
|
|
|
@ -15,9 +15,9 @@ var obj = {};
|
|||
var p = Promise.resolve(obj);
|
||||
|
||||
p.catch(function() {
|
||||
$ERROR("Should not be called - promise is fulfilled");
|
||||
throw new Test262Error("Should not be called - promise is fulfilled");
|
||||
}).then(function(arg) {
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected promise to be fulfilled with obj, got " + arg);
|
||||
throw new Test262Error("Expected promise to be fulfilled with obj, got " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -15,9 +15,9 @@ var obj = {};
|
|||
var p = Promise.reject(obj);
|
||||
|
||||
p.then(function() {
|
||||
$ERROR("Should not be called: did not expect promise to be fulfilled");
|
||||
throw new Test262Error("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);
|
||||
throw new Test262Error("Should have been rejected with reason obj, got " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -19,7 +19,7 @@ p.finally(function() {
|
|||
assert.sameValue(arguments.length, 0, 'onFinally receives zero args');
|
||||
return replacement;
|
||||
}).then(function() {
|
||||
$ERROR('promise is rejected pre-finally; onFulfill should not be called');
|
||||
throw new Test262Error('promise is rejected pre-finally; onFulfill should not be called');
|
||||
}).catch(function(reason) {
|
||||
sequence.push(2);
|
||||
assert.sameValue(reason, original, 'onFinally can not override the rejection value by returning');
|
||||
|
|
|
@ -19,7 +19,7 @@ p.finally(function() {
|
|||
assert.sameValue(arguments.length, 0, 'onFinally receives zero args');
|
||||
throw thrown;
|
||||
}).then(function() {
|
||||
$ERROR('promise is rejected; onFulfill should not be called');
|
||||
throw new Test262Error('promise is rejected; onFulfill should not be called');
|
||||
}).catch(function(reason) {
|
||||
sequence.push(2);
|
||||
assert.sameValue(reason, thrown, 'onFinally can override the rejection reason by throwing');
|
||||
|
|
|
@ -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");
|
||||
throw new Test262Error("Expected Promise.prototype.then to be a function");
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ description: Promise.prototype.then is a function of two arguments
|
|||
var p = new Promise(function() {});
|
||||
|
||||
if (!(p.then instanceof Function)) {
|
||||
$ERROR("Expected p.then to be a function");
|
||||
throw new Test262Error("Expected p.then to be a function");
|
||||
}
|
||||
|
||||
if (p.then.length !== 2) {
|
||||
$ERROR("Expected p.then to be a function of two arguments");
|
||||
throw new Test262Error("Expected p.then to be a function of two arguments");
|
||||
}
|
||||
|
|
|
@ -17,6 +17,6 @@ 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);
|
||||
throw new Test262Error("Expected resolution object to be passed through, got " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -15,9 +15,9 @@ var obj = {};
|
|||
var p = Promise.reject(obj);
|
||||
|
||||
p.then(undefined, undefined).then(function() {
|
||||
$ERROR("Should not be called -- promise was rejected.");
|
||||
throw new Test262Error("Should not be called -- promise was rejected.");
|
||||
}, function(arg) {
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected resolution object to be passed through, got " + arg);
|
||||
throw new Test262Error("Expected resolution object to be passed through, got " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -17,6 +17,6 @@ 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);
|
||||
throw new Test262Error("Expected resolution object to be passed through, got " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -15,9 +15,9 @@ var obj = {};
|
|||
var p = Promise.reject(obj);
|
||||
|
||||
p.then(3, 5).then(function() {
|
||||
$ERROR("Should not be called -- promise was rejected.");
|
||||
throw new Test262Error("Should not be called -- promise was rejected.");
|
||||
}, function(arg) {
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected resolution object to be passed through, got " + arg);
|
||||
throw new Test262Error("Expected resolution object to be passed through, got " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -23,7 +23,7 @@ sequence.push(1);
|
|||
pReject();
|
||||
|
||||
p.then(function() {
|
||||
$ERROR("Should not be called -- Promise rejected.");
|
||||
throw new Test262Error("Should not be called -- Promise rejected.");
|
||||
}, function() {
|
||||
sequence.push(3);
|
||||
assert.sameValue(sequence.length, 3);
|
||||
|
@ -33,7 +33,7 @@ p.then(function() {
|
|||
Promise.resolve().then(function() {
|
||||
// enqueue another then-handler
|
||||
p.then(function() {
|
||||
$ERROR("Should not be called (2) -- Promise rejected.");
|
||||
throw new Test262Error("Should not be called (2) -- Promise rejected.");
|
||||
}, function() {
|
||||
sequence.push(5);
|
||||
assert.sameValue(sequence.length, 5);
|
||||
|
|
|
@ -15,7 +15,7 @@ info: |
|
|||
|
||||
var object = {
|
||||
get constructor() {
|
||||
$ERROR("get constructor called");
|
||||
throw new Test262Error("get constructor called");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ Object.defineProperty(p, "constructor", {
|
|||
|
||||
assert.throws(Test262Error, function() {
|
||||
p.then(function() {
|
||||
$ERROR("Should never be called.");
|
||||
throw new Test262Error("Should never be called.");
|
||||
}, function() {
|
||||
$ERROR("Should never be called.");
|
||||
throw new Test262Error("Should never be called.");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -9,5 +9,5 @@ description: Promise.race is callable
|
|||
---*/
|
||||
|
||||
if (typeof Promise.race !== "function") {
|
||||
$ERROR("Expected Promise.race to be a function, actually " + typeof Promise.race);
|
||||
throw new Test262Error("Expected Promise.race to be a function, actually " + typeof Promise.race);
|
||||
}
|
||||
|
|
|
@ -11,5 +11,5 @@ description: Promise.race returns a new promise
|
|||
var p = Promise.race([]);
|
||||
|
||||
if (!(p instanceof Promise)) {
|
||||
$ERROR("Expected Promise.race([]) to return a promise.");
|
||||
throw new Test262Error("Expected Promise.race([]) to return a promise.");
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ flags: [async]
|
|||
var nonIterable = 3;
|
||||
|
||||
Promise.race(nonIterable).then(function() {
|
||||
$ERROR('Promise unexpectedly fulfilled: Promise.race(nonIterable) should throw TypeError');
|
||||
throw new Test262Error('Promise unexpectedly fulfilled: Promise.race(nonIterable) should throw TypeError');
|
||||
}, function(err) {
|
||||
if (!(err instanceof TypeError)) {
|
||||
$ERROR('Expected TypeError, got ' + err);
|
||||
throw new Test262Error('Expected TypeError, got ' + err);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -10,9 +10,9 @@ flags: [async]
|
|||
---*/
|
||||
|
||||
Promise.race(new Error("abrupt")).then(function() {
|
||||
$ERROR('Promise unexpectedly resolved: Promise.race(abruptCompletion) should throw TypeError');
|
||||
throw new Test262Error('Promise unexpectedly resolved: Promise.race(abruptCompletion) should throw TypeError');
|
||||
}, function(err) {
|
||||
if (!(err instanceof TypeError)) {
|
||||
$ERROR('Expected TypeError, got ' + err);
|
||||
throw new Test262Error('Expected TypeError, got ' + err);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -21,9 +21,9 @@ Object.defineProperty(iterThrows, Symbol.iterator, {
|
|||
});
|
||||
|
||||
Promise.race(iterThrows).then(function() {
|
||||
$ERROR('Promise unexpectedly fulfilled: Promise.race(iterThrows) should throw');
|
||||
throw new Test262Error('Promise unexpectedly fulfilled: Promise.race(iterThrows) should throw');
|
||||
}, function(err) {
|
||||
if (!(err instanceof Error)) {
|
||||
$ERROR('Expected Promise to be rejected with an error, got ' + err);
|
||||
throw new Test262Error('Expected Promise to be rejected with an error, got ' + err);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -20,7 +20,7 @@ iterThrows[Symbol.iterator] = function() {
|
|||
};
|
||||
|
||||
Promise.race(iterThrows).then(function() {
|
||||
$ERROR('Promise unexpectedly fulfilled: Promise.race(iterThrows) should throw TypeError');
|
||||
throw new Test262Error('Promise unexpectedly fulfilled: Promise.race(iterThrows) should throw TypeError');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -27,9 +27,9 @@ Object.defineProperty(iterThrows, Symbol.iterator, {
|
|||
});
|
||||
|
||||
Promise.race(iterThrows).then(function() {
|
||||
$ERROR('Promise unexpectedly fulfilled: Promise.race(iterThrows) should throw TypeError');
|
||||
throw new Test262Error('Promise unexpectedly fulfilled: Promise.race(iterThrows) should throw TypeError');
|
||||
}, function(err) {
|
||||
if (!(err instanceof TypeError)) {
|
||||
$ERROR('Expected TypeError, got ' + err);
|
||||
throw new Test262Error('Expected TypeError, got ' + err);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -11,11 +11,11 @@ flags: [async]
|
|||
var p = Promise.race([]);
|
||||
|
||||
p.then(function() {
|
||||
$ERROR("Never settles.");
|
||||
throw new Test262Error("Never settles.");
|
||||
}, function() {
|
||||
$ERROR("Never settles.");
|
||||
throw new Test262Error("Never settles.");
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
// use three 'then's to allow above to settle
|
||||
// use three 'then's to allow above to settle
|
||||
// if this is a buggy Promise.race implementation
|
||||
Promise.resolve().then().then().then($DONE, $DONE);
|
||||
|
|
|
@ -17,7 +17,7 @@ var p1 = Promise.reject(1),
|
|||
sequence.push(1);
|
||||
|
||||
p.then(function() {
|
||||
$ERROR("Should not fulfill.");
|
||||
throw new Test262Error("Should not fulfill.");
|
||||
}, function() {
|
||||
sequence.push(4);
|
||||
assert.sameValue(sequence.length, 4);
|
||||
|
|
|
@ -19,7 +19,7 @@ sequence.push(1);
|
|||
|
||||
p.then(function(arg) {
|
||||
if (arg !== 1) {
|
||||
$ERROR("Expected promise to be fulfilled with 1, got " + arg);
|
||||
throw new Test262Error("Expected promise to be fulfilled with 1, got " + arg);
|
||||
}
|
||||
|
||||
sequence.push(4);
|
||||
|
|
|
@ -19,7 +19,7 @@ sequence.push(1);
|
|||
|
||||
p.then(function(arg) {
|
||||
if (arg !== 1) {
|
||||
$ERROR("Expected promise to be fulfilled with 1, got " + arg);
|
||||
throw new Test262Error("Expected promise to be fulfilled with 1, got " + arg);
|
||||
}
|
||||
|
||||
sequence.push(4);
|
||||
|
|
|
@ -19,7 +19,7 @@ sequence.push(1);
|
|||
|
||||
p.then(function(arg) {
|
||||
if (arg !== 2) {
|
||||
$ERROR("Expected promise to be fulfilled with 2, got " + arg);
|
||||
throw new Test262Error("Expected promise to be fulfilled with 2, got " + arg);
|
||||
}
|
||||
|
||||
sequence.push(4);
|
||||
|
|
|
@ -18,10 +18,10 @@ var p1 = Promise.reject(1),
|
|||
sequence.push(1);
|
||||
|
||||
p.then(function() {
|
||||
$ERROR("Should not be fulfilled - expected rejection.");
|
||||
throw new Test262Error("Should not be fulfilled - expected rejection.");
|
||||
}, function(arg) {
|
||||
if (arg !== 1) {
|
||||
$ERROR("Expected rejection reason to be 1, got " + arg);
|
||||
throw new Test262Error("Expected rejection reason to be 1, got " + arg);
|
||||
}
|
||||
|
||||
sequence.push(4);
|
||||
|
|
|
@ -21,6 +21,6 @@ resolveP1(1);
|
|||
|
||||
Promise.race([p1, p2]).then(function(arg) {
|
||||
if (arg !== 1) {
|
||||
$ERROR("Expected fulfillment with 1, got " + arg);
|
||||
throw new Test262Error("Expected fulfillment with 1, got " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -17,10 +17,10 @@ var resolveP1, rejectP2,
|
|||
});
|
||||
|
||||
Promise.race([p1, p2]).then(function() {
|
||||
$ERROR("Should not be fulfilled: expected rejection.");
|
||||
throw new Test262Error("Should not be fulfilled: expected rejection.");
|
||||
}, function(arg) {
|
||||
if (arg !== 2) {
|
||||
$ERROR("Expected rejection reason to be 2, got " + arg);
|
||||
throw new Test262Error("Expected rejection reason to be 2, got " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ CustomPromise.resolve = function() {
|
|||
|
||||
Promise.race.call(CustomPromise, [1])
|
||||
.then(function() {
|
||||
$ERROR('The promise should be rejected.');
|
||||
throw new Test262Error('The promise should be rejected.');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, err);
|
||||
$DONE();
|
||||
|
|
|
@ -31,7 +31,7 @@ Object.defineProperty(Promise, 'resolve', {
|
|||
});
|
||||
|
||||
Promise.race([new Promise(function() {})]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
throw new Test262Error('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -32,7 +32,7 @@ promise.then = function() {
|
|||
};
|
||||
|
||||
Promise.race([promise]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
throw new Test262Error('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -33,7 +33,7 @@ Object.defineProperty(promise, 'then', {
|
|||
});
|
||||
|
||||
Promise.race([promise]).then(function() {
|
||||
$ERROR('The promise should be rejected');
|
||||
throw new Test262Error('The promise should be rejected');
|
||||
}, function(reason) {
|
||||
assert.sameValue(reason, error);
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -31,7 +31,7 @@ Object.defineProperty(poisonedDone, 'done', {
|
|||
});
|
||||
Object.defineProperty(poisonedDone, 'value', {
|
||||
get: function() {
|
||||
$ERROR('The `value` property should not be accessed.');
|
||||
throw new Test262Error('The `value` property should not be accessed.');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ Object.defineProperty(poisonedDone, 'done', {
|
|||
});
|
||||
Object.defineProperty(poisonedDone, 'value', {
|
||||
get: function() {
|
||||
$ERROR('The `value` property should not be accessed.');
|
||||
throw new Test262Error('The `value` property should not be accessed.');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -10,5 +10,5 @@ description: Promise.reject is a function
|
|||
---*/
|
||||
|
||||
if ((typeof Promise.reject) !== "function") {
|
||||
$ERROR("Expected Promise.reject to be a function");
|
||||
throw new Test262Error("Expected Promise.reject to be a function");
|
||||
}
|
||||
|
|
|
@ -19,13 +19,13 @@ flags: [async]
|
|||
var p = Promise.reject(3);
|
||||
|
||||
if (!(p instanceof Promise)) {
|
||||
$ERROR("Expected Promise.reject to return a promise.");
|
||||
throw new Test262Error("Expected Promise.reject to return a promise.");
|
||||
}
|
||||
|
||||
p.then(function() {
|
||||
$ERROR("Promise should not be fulfilled.");
|
||||
throw new Test262Error("Promise should not be fulfilled.");
|
||||
}, function(arg) {
|
||||
if (arg !== 3) {
|
||||
$ERROR("Expected promise to be rejected with supplied arg, got " + arg);
|
||||
throw new Test262Error("Expected promise to be rejected with supplied arg, got " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -10,5 +10,5 @@ description: Promise.resolve is a function
|
|||
---*/
|
||||
|
||||
if ((typeof Promise.resolve) !== "function") {
|
||||
$ERROR("Expected Promise.resolve to be a function");
|
||||
throw new Test262Error("Expected Promise.resolve to be a function");
|
||||
}
|
||||
|
|
|
@ -11,5 +11,5 @@ var p1 = Promise.resolve(1),
|
|||
p2 = Promise.resolve(p1);
|
||||
|
||||
if (p1 !== p2) {
|
||||
$ERROR("Expected p1 === Promise.resolve(p1) because they have same constructor");
|
||||
throw new Test262Error("Expected p1 === Promise.resolve(p1) because they have same constructor");
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@ var resolveP1,
|
|||
obj = {};
|
||||
|
||||
if (p1 !== p2) {
|
||||
$ERROR("Expected p1 === Promise.resolve(p1) because they have same constructor");
|
||||
throw new Test262Error("Expected p1 === Promise.resolve(p1) because they have same constructor");
|
||||
}
|
||||
|
||||
p2.then(function(arg) {
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected promise to be resolved with obj, actually " + arg);
|
||||
throw new Test262Error("Expected promise to be resolved with obj, actually " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@ var rejectP1,
|
|||
obj = {};
|
||||
|
||||
if (p1 !== p2) {
|
||||
$ERROR("Expected p1 === Promise.resolve(p1) because they have same constructor");
|
||||
throw new Test262Error("Expected p1 === Promise.resolve(p1) because they have same constructor");
|
||||
}
|
||||
|
||||
p2.then(function() {
|
||||
$ERROR("Expected p2 to be rejected, not fulfilled.");
|
||||
throw new Test262Error("Expected p2 to be rejected, not fulfilled.");
|
||||
}, function(arg) {
|
||||
if (arg !== obj) {
|
||||
$ERROR("Expected promise to be rejected with reason obj, actually " + arg);
|
||||
throw new Test262Error("Expected promise to be rejected with reason obj, actually " + arg);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@ var resolveP,
|
|||
resolveP(p);
|
||||
|
||||
p.then(function() {
|
||||
$ERROR("Should not fulfill: should reject with TypeError.");
|
||||
throw new Test262Error("Should not fulfill: should reject with TypeError.");
|
||||
}, function(err) {
|
||||
if (!(err instanceof TypeError)) {
|
||||
$ERROR("Expected TypeError, got " + err);
|
||||
throw new Test262Error("Expected TypeError, got " + err);
|
||||
}
|
||||
}).then($DONE, $DONE);
|
||||
|
|
|
@ -28,7 +28,7 @@ Object.defineProperty(poisonedThen, 'then', {
|
|||
});
|
||||
|
||||
Promise.resolve(poisonedThen).then(function() {
|
||||
$ERROR(
|
||||
throw new Test262Error(
|
||||
'Promise should be rejected when retrieving `then` property throws an error'
|
||||
);
|
||||
}, function(reason) {
|
||||
|
|
Loading…
Reference in New Issue