diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Temporal/Calendar/prototype/fields/argument-iterable-not-array.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Temporal/Calendar/prototype/fields/argument-iterable-not-array.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/fields/argument-iterable-not-array.js b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/fields/argument-iterable-not-array.js new file mode 100644 index 0000000000..ead494c99e --- /dev/null +++ b/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/fields/argument-iterable-not-array.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.fields +description: A non-Array iterable passed as the argument is exhausted +info: | + sec-temporal.calendar.prototype.fields step 4: + 4. Let _fieldNames_ be ? IterableToList(_fields_). +includes: [compareArray.js] +features: [Temporal] +---*/ + +const fieldNames = ["day", "month", "monthCode", "year"]; +const iterable = { + iteratorExhausted: false, + *[Symbol.iterator]() { + yield* fieldNames; + this.iteratorExhausted = true; + }, +}; + +const calendar = new Temporal.Calendar("iso8601"); +const result = calendar.fields(iterable); + +assert.compareArray(result, fieldNames); +assert(iterable.iteratorExhausted); + +reportCompare(0, 0); |