summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js')
-rw-r--r--js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js71
1 files changed, 71 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js
new file mode 100644
index 0000000000..73f8c49fe8
--- /dev/null
+++ b/js/src/tests/test262/built-ins/NativeErrors/AggregateError/errors-iterabletolist.js
@@ -0,0 +1,71 @@
+// Copyright (C) 2019 Leo Balter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-aggregate-error
+description: >
+ Iteration of errors
+info: |
+ AggregateError ( errors, message )
+
+ ...
+ 3. Let errorsList be ? IterableToList(errors).
+ 4. Set O.[[AggregateErrors]] to errorsList.
+ ...
+ 6. Return O.
+
+ Runtime Semantics: IterableToList ( items [ , method ] )
+
+ 1. If method is present, then
+ ...
+ 2. Else,
+ b. Let iteratorRecord be ? GetIterator(items, sync).
+ 3. Let values be a new empty List.
+ 4. Let next be true.
+ 5. Repeat, while next is not false
+ a. Set next to ? IteratorStep(iteratorRecord).
+ b. If next is not false, then
+ i. Let nextValue be ? IteratorValue(next).
+ ii. Append nextValue to the end of the List values.
+ 6. Return values.
+
+ GetIterator ( obj [ , hint [ , method ] ] )
+
+ ...
+ 3. If method is not present, then
+ a. If hint is async, then
+ ...
+ b. Otherwise, set method to ? GetMethod(obj, @@iterator).
+ 4. Let iterator be ? Call(method, obj).
+ 5. If Type(iterator) is not Object, throw a TypeError exception.
+ 6. Let nextMethod be ? GetV(iterator, "next").
+ ...
+ 8. Return iteratorRecord.
+features: [AggregateError, Symbol.iterator]
+includes: [compareArray.js]
+---*/
+
+var count = 0;
+var values = [];
+var case1 = {
+ [Symbol.iterator]() {
+ return {
+ next() {
+ count += 1;
+ return {
+ done: count === 3,
+ get value() {
+ values.push(count)
+ }
+ };
+ }
+ };
+ }
+};
+
+new AggregateError(case1);
+
+assert.sameValue(count, 3);
+assert.compareArray(values, [1, 2]);
+
+reportCompare(0, 0);