Add test for 12.4.21 of Temporal (#3036)

* Add test for 12.4.21 of Temporal

12.4.21 Temporal.Calendar.prototype.fields ( fields )
https://tc39.es/proposal-temporal/#sec-temporal.calendar.prototype.fields

@sffc @Ms2ger @ryzokuken @ljharb

* move to the right file

* remove from wrong place
This commit is contained in:
Frank Yung-Fong Tang 2021-07-13 16:39:07 -07:00 committed by GitHub
parent 356afd79a8
commit f1f3a2d542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,27 @@
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.fields
description: Temporal.Calendar.prototype.fields will take iterable of any size and any string
and return Array of the same content.
info: |
## 12.4.21 Temporal.Calendar.prototype.fields ( fields )
1. Let calendar be the this value.
2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
3. Assert: calendar.[[Identifier]] is "iso8601".
4. Let fieldNames be ? IterableToListOfType(fields, « String »).
5. Return ! CreateArrayFromList(fieldNames).
features: [Temporal]
includes: [compareArray.js]
---*/
let cal = new Temporal.Calendar("iso8601")
const fields = {
*[Symbol.iterator]() {
let i = 0;
while (i++ < 1000001) {
yield "garbage " + i;
}
}
}
assert(compareArray(cal.fields(fields), Array.from(fields)));