iter-arg-is-string-resolve.js 929 B

1234567891011121314151617181920212223242526272829303132333435
  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. Resolve when argument is a string
  7. info: |
  8. Promise.allSettled ( iterable )
  9. ...
  10. 4. Let iteratorRecord be GetIterator(iterable).
  11. 5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
  12. ...
  13. #sec-getiterator
  14. GetIterator ( obj [ , hint [ , method ] ] )
  15. ...
  16. Let iterator be ? Call(method, obj).
  17. If Type(iterator) is not Object, throw a TypeError exception.
  18. ...
  19. features: [Promise.allSettled, Symbol.iterator]
  20. flags: [async]
  21. ---*/
  22. try {
  23. Promise.allSettled('').then(function(v) {
  24. assert.sameValue(v.length, 0);
  25. }, function() {
  26. $DONE('The promise should be resolved, but was rejected');
  27. }).then($DONE, $DONE);
  28. } catch (error) {
  29. $DONE(`The promise should be resolved, but threw an exception: ${error.message}`);
  30. }