summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/fields/argument-iterable-not-array.js
blob: ead494c99e47920ab652b4727ace2be59d60e08f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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);