From ba3b432a1c05422d4e7f500d629b86d24979c46b Mon Sep 17 00:00:00 2001 From: Ben Allen Date: Sun, 2 Nov 2025 17:26:04 -0800 Subject: [PATCH] Added tests to Temporal.PlainDate, Temporal.PlainDateTime, and Temporal.ZonedDateTime ensuring weekOfYear only defined for "iso8601" calendar --- .../from/week-numbers-only-in-iso-8601.js | 47 ++++++++++++++++++ .../from/week-numbers-only-in-iso-8601.js | 47 ++++++++++++++++++ .../from/week-numbers-only-in-iso-8601.js | 49 +++++++++++++++++++ 3 files changed, 143 insertions(+) create mode 100644 test/intl402/Temporal/PlainDate/from/week-numbers-only-in-iso-8601.js create mode 100644 test/intl402/Temporal/PlainDateTime/from/week-numbers-only-in-iso-8601.js create mode 100644 test/intl402/Temporal/ZonedDateTime/from/week-numbers-only-in-iso-8601.js diff --git a/test/intl402/Temporal/PlainDate/from/week-numbers-only-in-iso-8601.js b/test/intl402/Temporal/PlainDate/from/week-numbers-only-in-iso-8601.js new file mode 100644 index 00000000000..8833adbf200 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/from/week-numbers-only-in-iso-8601.js @@ -0,0 +1,47 @@ +// Copyright (C) 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.from +description: Ensures that `"iso8601"` only calendar with non-`undefined` `weekOfYear` +features: [Temporal, Intl.Era-monthcode] +---*/ + +const nonIsoCalendars = [ + "buddhist", + "chinese", + "coptic", + "dangi", + "ethioaa", + "ethiopic", + "ethiopic-amete-alem", + "gregory", + "hebrew", + "indian", + "islamic-civil", + "islamic-tbla", + "islamic-umalqura", + "islamicc", + "japanese", + "persian", + "roc" +]; + +for (const calendar of nonIsoCalendars){ + const plainDate = Temporal.PlainDate.from({ + calendar, + year: 1, + month: 1, + day: 1 + }); + assert.sameValue(calendar.weekOfYear === undefined, true, "weekOfYear for " + calendar.calendarId + " should be undefined"); +} + +const isoCalendar = Temporal.PlainDate.from({ + calendar: "iso8601", + year: 1, + month: 1, + day: 1, +}); + +assert.sameValue(isoCalendar.weekOfYear !== undefined, true, "weekOfYear should not be undefined for 'iso8601' calendar"); diff --git a/test/intl402/Temporal/PlainDateTime/from/week-numbers-only-in-iso-8601.js b/test/intl402/Temporal/PlainDateTime/from/week-numbers-only-in-iso-8601.js new file mode 100644 index 00000000000..cf4da0a92fb --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/from/week-numbers-only-in-iso-8601.js @@ -0,0 +1,47 @@ +// Copyright (C) 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.from +description: Ensures that `"iso8601"` only calendar with non-`undefined` `weekOfYear` +features: [Temporal, Intl.Era-monthcode] +---*/ + +const nonIsoCalendars = [ + "buddhist", + "chinese", + "coptic", + "dangi", + "ethioaa", + "ethiopic", + "ethiopic-amete-alem", + "gregory", + "hebrew", + "indian", + "islamic-civil", + "islamic-tbla", + "islamic-umalqura", + "islamicc", + "japanese", + "persian", + "roc" +]; + +for (const calendar of nonIsoCalendars){ + const plainDate = Temporal.PlainDateTime.from({ + calendar, + year: 1, + month: 1, + day: 1 + }); + assert.sameValue(calendar.weekOfYear === undefined, true, "weekOfYear for " + calendar.calendarId + " should be undefined"); +} + +const isoCalendar = Temporal.PlainDateTime.from({ + calendar: "iso8601", + year: 1, + month: 1, + day: 1, +}); + +assert.sameValue(isoCalendar.weekOfYear !== undefined, true, "weekOfYear should not be undefined for 'iso8601' calendar"); diff --git a/test/intl402/Temporal/ZonedDateTime/from/week-numbers-only-in-iso-8601.js b/test/intl402/Temporal/ZonedDateTime/from/week-numbers-only-in-iso-8601.js new file mode 100644 index 00000000000..a994a8dd036 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/from/week-numbers-only-in-iso-8601.js @@ -0,0 +1,49 @@ +// Copyright (C) 2025 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: Ensures that `"iso8601"` only calendar with non-`undefined` `weekOfYear` +features: [Temporal, Intl.Era-monthcode] +---*/ + +const nonIsoCalendars = [ + "buddhist", + "chinese", + "coptic", + "dangi", + "ethioaa", + "ethiopic", + "ethiopic-amete-alem", + "gregory", + "hebrew", + "indian", + "islamic-civil", + "islamic-tbla", + "islamic-umalqura", + "islamicc", + "japanese", + "persian", + "roc" +]; + +for (const calendar of nonIsoCalendars){ + const plainDate = Temporal.ZonedDateTime.from({ + calendar, + year: 1, + month: 1, + day: 1, + timeZone: "UTC" + }); + assert.sameValue(calendar.weekOfYear === undefined, true, "weekOfYear for " + calendar.calendarId + " should be undefined"); +} + +const isoCalendar = Temporal.ZonedDateTime.from({ + calendar: "iso8601", + year: 1, + month: 1, + day: 1, + timeZone: "UTC" +}); + +assert.sameValue(isoCalendar.weekOfYear !== undefined, true, "weekOfYear should not be undefined for 'iso8601' calendar");