-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add more tests for T*.Calendar.p*.fields
- Loading branch information
1 parent
f5267ac
commit c3eb263
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
test/built-ins/Temporal/Calendar/prototype/fields/reverse.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// 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]]). | ||
4. Let iteratorRecord be ? Getiterator(fields, sync). | ||
5. Let fieldNames be a new empty List. | ||
6. Let next be true. | ||
7. 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). | ||
iv. If nextValue is not one of "year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", then | ||
1. Let completion be ThrowCompletion(a newly created RangeError object). | ||
2. Return ? IteratorClose(iteratorRecord, completion). | ||
features: [Symbol, Symbol.iterator, Temporal, computed-property-names, generators] | ||
includes: [compareArray.js] | ||
---*/ | ||
let cal = new Temporal.Calendar("iso8601") | ||
const fields = { | ||
*[Symbol.iterator]() { | ||
yield "nanosecond"; | ||
yield "microsecond"; | ||
yield "millisecond"; | ||
yield "second"; | ||
yield "minute"; | ||
yield "hour"; | ||
yield "day"; | ||
yield "monthCode"; | ||
yield "month"; | ||
yield "year"; | ||
} | ||
} | ||
assert(compareArray(cal.fields(fields), Array.from(fields)), | ||
'valid fields should return true even if they are in reversed order of the spec'); |