Debian Codegraph @

js/src/tests/test262/built-ins/Temporal/PlainYearMonth/from/argument-string.js

raw
1 // |reftest| shell-option(--enable-temporal) skip-if(!this.hasOwnProperty('Temporal')||!xulRuntime.shell) -- Temporal is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2021 Igalia, S.L. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 esid: sec-temporal.plainyearmonth.from
7 description: A string is parsed into the correct object when passed as the argument
8 includes: [temporalHelpers.js]
9 features: [Temporal]
10 ---*/
11
12 for (const input of TemporalHelpers.ISO.plainYearMonthStringsValid()) {
13 const plainYearMonth = Temporal.PlainYearMonth.from(input);
14 TemporalHelpers.assertPlainYearMonth(plainYearMonth, 1976, 11, "M11");
15 assert.sameValue(plainYearMonth.calendarId, "iso8601", "calendar string should be iso8601");
16 assert.sameValue(plainYearMonth.toString({ calendarName: "always" }), "1976-11-01[u-ca=iso8601]", "iso reference date");
17 }
18
19 for (const input of TemporalHelpers.ISO.plainYearMonthStringsValidNegativeYear()) {
20 const plainYearMonth = Temporal.PlainYearMonth.from(input);
21 TemporalHelpers.assertPlainYearMonth(plainYearMonth, -9999, 11, "M11");
22 assert.sameValue(plainYearMonth.calendarId, "iso8601", "calendar string should be iso8601");
23 assert.sameValue(plainYearMonth.toString({ calendarName: "always" }), "-009999-11-01[u-ca=iso8601]", "iso reference date");
24 }
25
26 reportCompare(0, 0);