| 1 |
// |reftest| async |
| 2 |
// Copyright (C) 2019 Sergey Rubanov. All rights reserved. |
| 3 |
// This code is governed by the BSD license found in the LICENSE file. |
| 4 |
|
| 5 |
/*--- |
| 6 |
esid: sec-promise.any |
| 7 |
description: > |
| 8 |
Reject when argument's Symbol.iterator property has the value false |
| 9 |
info: | |
| 10 |
Promise.any ( iterable ) |
| 11 |
|
| 12 |
... |
| 13 |
4. Let iteratorRecord be GetIterator(iterable). |
| 14 |
5. IfAbruptRejectPromise(iteratorRecord, promiseCapability). |
| 15 |
... |
| 16 |
|
| 17 |
GetIterator ( obj [ , hint [ , method ] ] ) |
| 18 |
|
| 19 |
... |
| 20 |
3. If method is not present, then |
| 21 |
a. If hint is async, then |
| 22 |
i. Set method to ? GetMethod(obj, @@asyncIterator). |
| 23 |
ii. If method is undefined, then |
| 24 |
1. Let syncMethod be ? GetMethod(obj, @@iterator). |
| 25 |
2. Let syncIteratorRecord be ? GetIterator(obj, sync, syncMethod). |
| 26 |
... |
| 27 |
4. Let iterator be ? Call(method, obj). |
| 28 |
... |
| 29 |
|
| 30 |
GetMethod |
| 31 |
|
| 32 |
2. Let func be ? GetV(V, P). |
| 33 |
3. If func is either undefined or null, return undefined. |
| 34 |
4. If IsCallable(func) is false, throw a TypeError exception. |
| 35 |
|
| 36 |
Call ( F, V [ , argumentsList ] ) |
| 37 |
|
| 38 |
2. If IsCallable(F) is false, throw a TypeError exception. |
| 39 |
features: [Promise.any, Symbol.iterator, Symbol, computed-property-names] |
| 40 |
flags: [async] |
| 41 |
---*/ |
| 42 |
|
| 43 |
try { |
| 44 |
Promise.any({ |
| 45 |
[Symbol.iterator]: false |
| 46 |
}).then(function() { |
| 47 |
$DONE('The promise should be rejected, but was resolved'); |
| 48 |
}, function(error) { |
| 49 |
assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype); |
| 50 |
assert(error instanceof TypeError); |
| 51 |
}).then($DONE, $DONE); |
| 52 |
} catch (error) { |
| 53 |
$DONE(`The promise should be rejected, but threw an exception: ${error.message}`); |
| 54 |
} |