2020-03-18 19:21:32 +01:00
|
|
|
// Copyright (C) 2019 Sergey Rubanov. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
|
|
|
/*---
|
|
|
|
description: >
|
|
|
|
Invocation of the constructor's `resolve` method for iterable with promise values
|
|
|
|
esid: sec-promise.any
|
|
|
|
info: |
|
|
|
|
5. Let result be PerformPromiseAny(iteratorRecord, C, promiseCapability).
|
|
|
|
|
|
|
|
Runtime Semantics: PerformPromiseAny
|
|
|
|
|
|
|
|
8. Repeat
|
|
|
|
...
|
|
|
|
i. Let nextPromise be ? Call(promiseResolve, constructor, « nextValue »).
|
|
|
|
|
|
|
|
flags: [async]
|
2020-03-24 17:10:16 +01:00
|
|
|
features: [Promise.any, arrow-function]
|
2020-03-18 19:21:32 +01:00
|
|
|
---*/
|
|
|
|
|
2020-03-24 03:39:53 +01:00
|
|
|
let values = [1,1,1];
|
2020-03-18 19:21:32 +01:00
|
|
|
let callCount = 0;
|
|
|
|
let boundPromiseResolve = Promise.resolve.bind(Promise);
|
|
|
|
|
|
|
|
Promise.resolve = function(...args) {
|
|
|
|
callCount += 1;
|
|
|
|
return boundPromiseResolve(...args);
|
|
|
|
};
|
|
|
|
|
2020-03-24 03:39:53 +01:00
|
|
|
Promise.any(values)
|
2020-03-18 19:21:32 +01:00
|
|
|
.then(() => {
|
|
|
|
assert.sameValue(callCount, 3, '`then` invoked once for every iterated promise');
|
2020-06-24 21:22:00 +02:00
|
|
|
}).then($DONE, $DONE);
|
2020-03-18 19:21:32 +01:00
|
|
|
|