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