iter-assigned-string-reject.js 1.4 KB

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