mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Promise.any: review fixes
This commit is contained in:
parent
f70e3e3cf1
commit
5d3eafc547
@ -16,9 +16,9 @@ info: |
|
||||
features: [Promise.any]
|
||||
---*/
|
||||
|
||||
var CustomPromise = function() {
|
||||
function CustomPromise() {
|
||||
throw new Test262Error();
|
||||
};
|
||||
}
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Promise.any.call(CustomPromise);
|
||||
|
@ -13,9 +13,11 @@ info: |
|
||||
|
||||
1. If IsConstructor(C) is false, throw a TypeError exception.
|
||||
|
||||
features: [Promise.any]
|
||||
features: [Promise.any, Symbol]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Promise.any, 'function');
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Promise.any.call(eval);
|
||||
});
|
||||
|
@ -19,11 +19,7 @@ features: [Promise.any]
|
||||
---*/
|
||||
class Custom extends Promise {}
|
||||
|
||||
let customs = [
|
||||
new Custom(resolve => resolve()),
|
||||
new Custom(resolve => resolve()),
|
||||
new Custom(resolve => resolve()),
|
||||
];
|
||||
let values = [1, 1, 1];
|
||||
let cresolveCallCount = 0;
|
||||
let presolveCallCount = 0;
|
||||
let boundCustomResolve = Custom.resolve.bind(Custom);
|
||||
@ -39,12 +35,9 @@ Promise.resolve = function(...args) {
|
||||
return boundPromiseResolve(...args);
|
||||
};
|
||||
|
||||
Promise.any.call(Custom, customs)
|
||||
Promise.any.call(Custom, values)
|
||||
.then(() => {
|
||||
assert.sameValue(presolveCallCount, 0, '`Promise.resolve` is never invoked');
|
||||
assert.sameValue(cresolveCallCount, 3, '`Custom.resolve` invoked once for every iterated promise');
|
||||
}, (error) => {
|
||||
$DONE(error);
|
||||
}
|
||||
).then($DONE, $DONE);
|
||||
}, $DONE).then($DONE, $DONE);
|
||||
|
||||
|
@ -18,11 +18,7 @@ flags: [async]
|
||||
features: [Promise.any]
|
||||
---*/
|
||||
|
||||
let promises = [
|
||||
new Promise(resolve => resolve()),
|
||||
new Promise(resolve => resolve()),
|
||||
new Promise(resolve => resolve()),
|
||||
];
|
||||
let values = [1,1,1];
|
||||
let callCount = 0;
|
||||
let boundPromiseResolve = Promise.resolve.bind(Promise);
|
||||
|
||||
@ -31,11 +27,8 @@ Promise.resolve = function(...args) {
|
||||
return boundPromiseResolve(...args);
|
||||
};
|
||||
|
||||
Promise.any(promises)
|
||||
Promise.any(values)
|
||||
.then(() => {
|
||||
assert.sameValue(callCount, 3, '`then` invoked once for every iterated promise');
|
||||
}, (error) => {
|
||||
$DONE(error);
|
||||
}
|
||||
).then($DONE, $DONE);
|
||||
}, $DONE).then($DONE, $DONE);
|
||||
|
||||
|
@ -39,8 +39,5 @@ Promise.any.call(Custom, values)
|
||||
.then(() => {
|
||||
assert.sameValue(presolveCallCount, 0, '`Promise.resolve` is never invoked');
|
||||
assert.sameValue(cresolveCallCount, 3, '`Custom.resolve` invoked once for every iterated promise');
|
||||
}, (error) => {
|
||||
$DONE(error);
|
||||
}
|
||||
).then($DONE, $DONE);
|
||||
}, $DONE).then($DONE, $DONE);
|
||||
|
||||
|
@ -30,8 +30,5 @@ Promise.resolve = function(...args) {
|
||||
Promise.any(values)
|
||||
.then(() => {
|
||||
assert.sameValue(callCount, 3, '`Promise.resolve` invoked once for every iterated value');
|
||||
}, (error) => {
|
||||
$DONE(error);
|
||||
}
|
||||
).then($DONE, $DONE);
|
||||
}, $DONE).then($DONE, $DONE);
|
||||
|
||||
|
@ -20,9 +20,9 @@ features: [Promise.any]
|
||||
---*/
|
||||
|
||||
let promises = [
|
||||
new Promise(resolve => resolve()),
|
||||
new Promise(resolve => resolve()),
|
||||
new Promise(resolve => resolve()),
|
||||
Promise.resolve(),
|
||||
Promise.resolve(),
|
||||
Promise.resolve(),
|
||||
];
|
||||
let callCount = 0;
|
||||
|
||||
@ -38,8 +38,4 @@ promises.forEach(promise => {
|
||||
Promise.any(promises)
|
||||
.then(() => {
|
||||
assert.sameValue(callCount, 3, '`then` invoked once for every iterated value');
|
||||
}, (error) => {
|
||||
$DONE(error);
|
||||
// $DONE('The promise should not be rejected');
|
||||
}
|
||||
).then($DONE, $DONE);
|
||||
}, $DONE).then($DONE, $DONE);
|
||||
|
@ -20,7 +20,7 @@ info: |
|
||||
Let iterator be ? Call(method, obj).
|
||||
If Type(iterator) is not Object, throw a TypeError exception.
|
||||
...
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
features: [Promise.any]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
|
@ -20,7 +20,7 @@ info: |
|
||||
Let iterator be ? Call(method, obj).
|
||||
If Type(iterator) is not Object, throw a TypeError exception.
|
||||
...
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
features: [Promise.any]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
|
@ -20,7 +20,7 @@ info: |
|
||||
Let iterator be ? Call(method, obj).
|
||||
If Type(iterator) is not Object, throw a TypeError exception.
|
||||
...
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
features: [Promise.any]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
|
@ -19,7 +19,7 @@ info: |
|
||||
...
|
||||
Let iterator be ? Call(method, obj).
|
||||
...
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
features: [Promise.any]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
|
@ -20,7 +20,7 @@ info: |
|
||||
Let iterator be ? Call(method, obj).
|
||||
If Type(iterator) is not Object, throw a TypeError exception.
|
||||
...
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
features: [Promise.any]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
|
@ -33,7 +33,7 @@ info: |
|
||||
Call ( F, V [ , argumentsList ] )
|
||||
|
||||
2. If IsCallable(F) is false, throw a TypeError exception.
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
features: [Promise.any, Symbol]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
|
@ -33,7 +33,7 @@ info: |
|
||||
Call ( F, V [ , argumentsList ] )
|
||||
|
||||
2. If IsCallable(F) is false, throw a TypeError exception.
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
features: [Promise.any]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
|
@ -33,7 +33,7 @@ info: |
|
||||
Call ( F, V [ , argumentsList ] )
|
||||
|
||||
2. If IsCallable(F) is false, throw a TypeError exception.
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
features: [Promise.any]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
|
@ -33,7 +33,7 @@ info: |
|
||||
Call ( F, V [ , argumentsList ] )
|
||||
|
||||
2. If IsCallable(F) is false, throw a TypeError exception.
|
||||
features: [Promise.any, Symbol.iterator]
|
||||
features: [Promise.any, Symbol, Symbol.iterator]
|
||||
flags: [async]
|
||||
---*/
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user