iter-arg-is-symbol-reject.js (1428B)
1 // |reftest| async 2 // Copyright (C) 2019 Leo Balter. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 esid: sec-promise.allsettled 7 description: > 8 Reject when argument is a symbol 9 info: | 10 Promise.allSettled ( 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 ... 23 b. Otherwise, set method to ? GetMethod(obj, @@iterator). 24 4. Let iterator be ? Call(method, obj). 25 5. If Type(iterator) is not Object, throw a TypeError exception. 26 ... 27 28 GetMethod 29 30 2. Let func be ? GetV(V, P). 31 3. If func is either undefined or null, return undefined. 32 4. If IsCallable(func) is false, throw a TypeError exception. 33 34 Call ( F, V [ , argumentsList ] ) 35 36 2. If IsCallable(F) is false, throw a TypeError exception. 37 features: [Promise.allSettled, Symbol.iterator] 38 flags: [async] 39 ---*/ 40 41 try { 42 Promise.allSettled(Symbol()).then(function() { 43 $DONE('The promise should be rejected, but was resolved'); 44 }, function(error) { 45 assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype); 46 assert(error instanceof TypeError); 47 }).then($DONE, $DONE); 48 } catch (error) { 49 $DONE(`The promise should be rejected, but threw an exception: ${error.message}`); 50 }