iter-arg-is-error-object-reject.js (1185B)
1 // |reftest| async 2 // Copyright (C) 2020 Rick Waldron. 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 Promise.any(new Test262Error()) rejects with TypeError. 9 info: | 10 Promise.any ( iterable ) 11 12 ... 13 Let iteratorRecord be GetIterator(iterable). 14 IfAbruptRejectPromise(iteratorRecord, promiseCapability). 15 ... 16 17 GetIterator ( obj [ , hint [ , method ] ] ) 18 19 ... 20 Let iterator be ? Call(method, obj). 21 If Type(iterator) is not Object, throw a TypeError exception. 22 ... 23 24 GetMethod 25 26 2. Let func be ? GetV(V, P). 27 3. If func is either undefined or null, return undefined. 28 4. If IsCallable(func) is false, throw a TypeError exception. 29 30 Call ( F, V [ , argumentsList ] ) 31 32 2. If IsCallable(F) is false, throw a TypeError exception. 33 features: [Promise.any] 34 flags: [async] 35 ---*/ 36 37 try { 38 Promise.any(new Test262Error()).then(() => { 39 $DONE('The promise should be rejected, but was resolved'); 40 }, (error) => { 41 assert(error instanceof TypeError); 42 }).then($DONE, $DONE); 43 } catch (error) { 44 $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); 45 }