From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- .../prototype/format/dayPeriod-long-en.js | 2 +- .../prototype/format/dayPeriod-narrow-en.js | 2 +- .../prototype/format/dayPeriod-short-en.js | 2 +- .../prototype/format/fractionalSecondDigits.js | 2 +- .../formatToParts/fractionalSecondDigits.js | 2 +- .../prototype/resolvedOptions/hourCycle-default.js | 38 ++++++---- .../DateTimeFormat/timezone-legacy-non-iana.js | 45 +++++++++++ .../prototype/of/type-region-invalid.js | 2 +- .../constructor-unit-style-defaults.js | 34 +++++++++ .../format/fractions-of-subsecond-units-en.js | 65 ++++++++++++++++ .../format/mixed-non-numeric-styles-es.js | 88 ++++++++++++++++++++++ .../prototype/format/mixed-short-and-numeric.js | 37 +++++++++ .../format/negative-duration-style-default-en.js | 2 +- .../format/negative-duration-style-short-en.js | 2 +- .../format/negative-durationstyle-digital-en.js | 2 +- .../format/negative-durationstyle-long-en.js | 2 +- .../format/negative-durationstyle-narrow-en.js | 2 +- ...-hour-with-zero-minutes-and-non-zero-seconds.js | 20 +---- .../format/precision-exact-mathematical-values.js | 2 +- .../prototype/format/style-default-en.js | 2 +- .../prototype/format/style-digital-en.js | 2 +- .../format/style-digital-fractionalDigits-en.js | 51 +++++++++++++ .../style-digital-fractionalDigits-undefined-en.js | 80 ++++++++++++++++++++ .../style-digital-fractionalDigits-undefined.js | 71 ----------------- .../format/style-digital-fractionalDigits.js | 50 ------------ .../prototype/format/style-long-en.js | 2 +- .../prototype/format/style-narrow-en.js | 2 +- .../prototype/format/style-short-en.js | 2 +- ...tive-duration-formatToParts-style-default-en.js | 2 +- ...tive-duration-formatToParts-style-digital-en.js | 2 +- ...egative-duration-formatToParts-style-long-en.js | 2 +- ...ative-duration-formatToParts-style-narrow-en.js | 2 +- ...gative-duration-formatToParts-style-short-en.js | 2 +- .../constructor-options-collation-invalid.js | 2 +- .../Locale/prototype/calendar/canonicalize.js | 22 ++++++ .../Temporal/Calendar/prototype/dateAdd/shell.js | 8 ++ .../Calendar/prototype/dateFromFields/shell.js | 8 ++ .../Temporal/Calendar/prototype/dateUntil/shell.js | 8 ++ .../Temporal/Calendar/prototype/day/shell.js | 8 ++ .../Temporal/Calendar/prototype/dayOfWeek/shell.js | 8 ++ .../Temporal/Calendar/prototype/dayOfYear/shell.js | 8 ++ .../Calendar/prototype/daysInMonth/shell.js | 8 ++ .../Calendar/prototype/daysInWeek/shell.js | 8 ++ .../Calendar/prototype/daysInYear/shell.js | 8 ++ .../argument-propertybag-calendar-iso-string.js | 28 +++++++ .../era/argument-propertybag-calendar-year-zero.js | 3 +- ...ument-string-calendar-annotation-invalid-key.js | 25 ++++++ .../Temporal/Calendar/prototype/era/shell.js | 8 ++ .../argument-propertybag-calendar-iso-string.js | 28 +++++++ .../argument-propertybag-calendar-year-zero.js | 3 +- ...ument-string-calendar-annotation-invalid-key.js | 25 ++++++ .../Temporal/Calendar/prototype/eraYear/shell.js | 8 ++ .../Calendar/prototype/inLeapYear/shell.js | 8 ++ .../Temporal/Calendar/prototype/month/shell.js | 8 ++ .../Temporal/Calendar/prototype/monthCode/shell.js | 8 ++ .../Calendar/prototype/monthDayFromFields/shell.js | 8 ++ .../Calendar/prototype/monthsInYear/shell.js | 8 ++ .../prototype/weekOfYear/gregory-iso-weekofyear.js | 30 ++++++++ .../prototype/weekOfYear/non-iso-week-of-year.js | 25 ++++++ .../Calendar/prototype/weekOfYear/shell.js | 8 ++ .../Temporal/Calendar/prototype/year/shell.js | 8 ++ .../prototype/yearMonthFromFields/shell.js | 8 ++ .../prototype/yearOfWeek/gregory-iso-weekofyear.js | 30 ++++++++ .../prototype/yearOfWeek/non-iso-week-of-year.js | 25 ++++++ .../Calendar/prototype/yearOfWeek/shell.js | 8 ++ .../Temporal/Duration/prototype/add/shell.js | 8 ++ .../Temporal/Duration/prototype/round/shell.js | 8 ++ .../Temporal/Duration/prototype/subtract/shell.js | 8 ++ .../Temporal/Duration/prototype/total/shell.js | 8 ++ .../Instant/prototype/toLocaleString/dateStyle.js | 31 ++++++++ .../intl402/Temporal/PlainDate/compare/shell.js | 8 ++ .../intl402/Temporal/PlainDate/from/shell.js | 8 ++ .../Temporal/PlainDate/prototype/equals/shell.js | 8 ++ .../Temporal/PlainDate/prototype/since/shell.js | 8 ++ .../prototype/toLocaleString/dateStyle.js | 34 +++++++++ .../Temporal/PlainDate/prototype/until/shell.js | 8 ++ .../PlainDate/prototype/weekOfYear/browser.js | 0 .../prototype/weekOfYear/gregory-iso-weekofyear.js | 30 ++++++++ .../prototype/weekOfYear/non-iso-week-of-year.js | 25 ++++++ .../PlainDate/prototype/weekOfYear/shell.js | 0 .../PlainDate/prototype/yearOfWeek/browser.js | 0 .../prototype/yearOfWeek/gregory-iso-weekofyear.js | 30 ++++++++ .../prototype/yearOfWeek/non-iso-week-of-year.js | 25 ++++++ .../PlainDate/prototype/yearOfWeek/shell.js | 0 .../Temporal/PlainDateTime/compare/shell.js | 8 ++ .../intl402/Temporal/PlainDateTime/from/shell.js | 8 ++ .../PlainDateTime/prototype/equals/shell.js | 8 ++ .../PlainDateTime/prototype/since/shell.js | 8 ++ .../prototype/toLocaleString/dateStyle.js | 34 +++++++++ .../PlainDateTime/prototype/until/shell.js | 8 ++ .../PlainDateTime/prototype/weekOfYear/browser.js | 0 .../prototype/weekOfYear/gregory-iso-weekofyear.js | 30 ++++++++ .../prototype/weekOfYear/non-iso-week-of-year.js | 25 ++++++ .../PlainDateTime/prototype/weekOfYear/shell.js | 0 .../PlainDateTime/prototype/withPlainDate/shell.js | 8 ++ .../PlainDateTime/prototype/yearOfWeek/browser.js | 0 .../prototype/yearOfWeek/gregory-iso-weekofyear.js | 30 ++++++++ .../prototype/yearOfWeek/non-iso-week-of-year.js | 25 ++++++ .../PlainDateTime/prototype/yearOfWeek/shell.js | 0 .../intl402/Temporal/PlainMonthDay/from/shell.js | 8 ++ .../PlainMonthDay/prototype/equals/shell.js | 8 ++ .../prototype/toLocaleString/dateStyle.js | 34 +++++++++ .../PlainMonthDay/prototype/toPlainDate/shell.js | 8 ++ .../PlainTime/prototype/toPlainDateTime/shell.js | 8 ++ .../PlainTime/prototype/toZonedDateTime/shell.js | 8 ++ .../Temporal/PlainYearMonth/compare/shell.js | 8 ++ .../intl402/Temporal/PlainYearMonth/from/shell.js | 8 ++ .../PlainYearMonth/prototype/equals/shell.js | 8 ++ .../PlainYearMonth/prototype/since/shell.js | 8 ++ .../prototype/toLocaleString/dateStyle.js | 34 +++++++++ .../PlainYearMonth/prototype/until/shell.js | 8 ++ .../from/timezone-string-legacy-non-iana.js | 47 ++++++++++++ .../intl402/Temporal/TimeZone/legacy-non-iana.js | 47 ++++++++++++ .../TimeZone/prototype/getInstantFor/shell.js | 8 ++ .../prototype/getPlainDateTimeFor/shell.js | 8 ++ .../prototype/getPossibleInstantsFor/shell.js | 8 ++ .../Temporal/ZonedDateTime/compare/shell.js | 8 ++ .../intl402/Temporal/ZonedDateTime/from/shell.js | 8 ++ .../ZonedDateTime/prototype/equals/shell.js | 8 ++ .../Temporal/ZonedDateTime/prototype/era/shell.js | 8 ++ .../ZonedDateTime/prototype/eraYear/shell.js | 8 ++ .../ZonedDateTime/prototype/since/shell.js | 8 ++ .../prototype/toLocaleString/dateStyle.js | 34 +++++++++ .../ZonedDateTime/prototype/until/shell.js | 8 ++ .../ZonedDateTime/prototype/weekOfYear/browser.js | 0 .../prototype/weekOfYear/gregory-iso-weekofyear.js | 30 ++++++++ .../prototype/weekOfYear/non-iso-week-of-year.js | 27 +++++++ .../ZonedDateTime/prototype/weekOfYear/shell.js | 0 .../Temporal/ZonedDateTime/prototype/with/shell.js | 8 ++ .../ZonedDateTime/prototype/withPlainDate/shell.js | 8 ++ .../ZonedDateTime/prototype/yearOfWeek/browser.js | 0 .../prototype/yearOfWeek/gregory-iso-weekofyear.js | 30 ++++++++ .../prototype/yearOfWeek/non-iso-week-of-year.js | 27 +++++++ .../ZonedDateTime/prototype/yearOfWeek/shell.js | 0 .../calls-toLocaleString-number-elements.js | 1 + 135 files changed, 1778 insertions(+), 177 deletions(-) create mode 100644 js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js create mode 100644 js/src/tests/test262/intl402/DurationFormat/constructor-unit-style-defaults.js create mode 100644 js/src/tests/test262/intl402/DurationFormat/prototype/format/fractions-of-subsecond-units-en.js create mode 100644 js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-non-numeric-styles-es.js create mode 100644 js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js create mode 100644 js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-en.js create mode 100644 js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined-en.js delete mode 100644 js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined.js delete mode 100644 js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits.js create mode 100644 js/src/tests/test262/intl402/Locale/prototype/calendar/canonicalize.js create mode 100644 js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js create mode 100644 js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js create mode 100644 js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js create mode 100644 js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js create mode 100644 js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js create mode 100644 js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js create mode 100644 js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js create mode 100644 js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js create mode 100644 js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/browser.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/shell.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/browser.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/shell.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/browser.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/shell.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/browser.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/shell.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js create mode 100644 js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js create mode 100644 js/src/tests/test262/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js create mode 100644 js/src/tests/test262/intl402/Temporal/TimeZone/legacy-non-iana.js create mode 100644 js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js create mode 100644 js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/browser.js create mode 100644 js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js create mode 100644 js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js create mode 100644 js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/shell.js create mode 100644 js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/browser.js create mode 100644 js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js create mode 100644 js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js create mode 100644 js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/shell.js (limited to 'js/src/tests/test262/intl402') diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js index 13b8f374b3..0e6761b04a 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-long-en.js @@ -5,7 +5,7 @@ esid: sec-createdatetimeformat description: Checks basic handling of dayPeriod, long format. features: [Intl.DateTimeFormat-dayPeriod] -locale: [en-US] +locale: [en] ---*/ const d0000 = new Date(2017, 11, 12, 0, 0, 0, 0); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js index 4d26a5131d..986ff1f157 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-narrow-en.js @@ -5,7 +5,7 @@ esid: sec-createdatetimeformat description: Checks basic handling of dayPeriod, narrow format. features: [Intl.DateTimeFormat-dayPeriod] -locale: [en-US] +locale: [en] ---*/ const d0000 = new Date(2017, 11, 12, 0, 0, 0, 0); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js index f7b410f24d..dec193c396 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/dayPeriod-short-en.js @@ -5,7 +5,7 @@ esid: sec-initializedatetimeformat description: Checks basic handling of dayPeriod, short format. features: [Intl.DateTimeFormat-dayPeriod] -locale: [en-US] +locale: [en] ---*/ const d0000 = new Date(2017, 11, 12, 0, 0, 0, 0); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js index 25af5ada6d..49218a3b39 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/format/fractionalSecondDigits.js @@ -5,7 +5,7 @@ esid: sec-createdatetimeformat description: Checks basic handling of fractionalSecondDigits. features: [Intl.DateTimeFormat-fractionalSecondDigits] -locale: [en-US] +locale: [en] ---*/ const d1 = new Date(2019, 7, 10, 1, 2, 3, 234); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js index 543dfb2274..046084493c 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/formatToParts/fractionalSecondDigits.js @@ -5,7 +5,7 @@ esid: sec-createdatetimeformat description: Checks basic handling of fractionalSecondDigits. features: [Intl.DateTimeFormat-fractionalSecondDigits] -locale: [en-US] +locale: [en] ---*/ const d1 = new Date(2019, 7, 10, 1, 2, 3, 234); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js b/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js index 9063e045a6..c2cccd826c 100644 --- a/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js +++ b/js/src/tests/test262/intl402/DateTimeFormat/prototype/resolvedOptions/hourCycle-default.js @@ -21,27 +21,35 @@ info: | c. If hc is null, set hc to dataLocaleData.[[hourCycle]]. 27. Set dateTimeFormat.[[HourCycle]] to hc. -locale: [en, fr, it, ja, zh, ko, ar, hi, en-u-hc-h24] +locale: [en, fr, it, ja, zh, ko, ar, hi] ---*/ -let locales = ["en", "fr", "it", "ja", "ja-u-hc-h11", "zh", "ko", "ar", "hi", "en-u-hc-h24"]; +let locales = ["en", "fr", "it", "ja", "zh", "ko", "ar", "hi"]; -locales.forEach(function(locale) { - let hcDefault = new Intl.DateTimeFormat(locale, { hour: "numeric" }).resolvedOptions().hourCycle; - if (hcDefault === "h11" || hcDefault === "h12") { - assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: true }).resolvedOptions().hourCycle, hcDefault); +for (let locale of locales) { + let hcDefault = new Intl.DateTimeFormat(locale, {hour: "numeric"}).resolvedOptions().hourCycle; + assert( + hcDefault === "h11" || hcDefault === "h12" || hcDefault === "h23" || hcDefault === "h24", + "hcDefault is one of [h11, h12, h23, h24]" + ); - // no locale has "h24" as a default. see https://github.com/tc39/ecma402/pull/758#issue-1622377292 - assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: false }).resolvedOptions().hourCycle, "h23"); - } + let hour12 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: true}).resolvedOptions().hourCycle; + assert(hour12 === "h11" || hour12 === "h12", "hour12 is one of [h11, h12]"); + + let hour24 = new Intl.DateTimeFormat(locale, {hour: "numeric", hour12: false}).resolvedOptions().hourCycle; + assert(hour24 === "h23" || hour24 === "h24", "hour24 is one of [h23, h24]"); - // however, "h24" can be set via locale extension. - if (hcDefault === "h23" || hcDefault === "h24") { - assert.sameValue(new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: false }).resolvedOptions().hourCycle, hcDefault); + if (hcDefault === "h11" || hcDefault === "h12") { + assert.sameValue(hour12, hcDefault, "hour12 matches hcDefault"); + } else { + assert.sameValue(hour24, hcDefault, "hour24 matches hcDefault"); } - let hcHour12 = new Intl.DateTimeFormat(locale, { hour: "numeric", hour12: true }).resolvedOptions().hourCycle; - assert(hcHour12 === "h11" || hcHour12 === "h12", "Expected `hourCycle`: " + hcHour12 + " to be in [\"h11\", \"h12\"]"); -}); + // 24-hour clock uses the "h23" format in all locales. + assert.sameValue(hour24, "h23"); + + // 12-hour clock uses the "h12" format in all locales except "ja". + assert.sameValue(hour12, locale === "ja" ? "h11" : "h12"); +} reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js b/js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js new file mode 100644 index 0000000000..d99cf18df4 --- /dev/null +++ b/js/src/tests/test262/intl402/DateTimeFormat/timezone-legacy-non-iana.js @@ -0,0 +1,45 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializedatetimeformat +description: Only IANA time zone identifiers are allowed. +---*/ + +// List of non-IANA link names, copied from: +// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones +const invalidTimeZones = [ + "ACT", + "AET", + "AGT", + "ART", + "AST", + "BET", + "BST", + "CAT", + "CNT", + "CST", + "CTT", + "EAT", + "ECT", + "IET", + "IST", + "JST", + "MIT", + "NET", + "NST", + "PLT", + "PNT", + "PRT", + "PST", + "SST", + "VST", +]; + +for (let timeZone of invalidTimeZones) { + assert.throws(RangeError, () => { + new Intl.DateTimeFormat(undefined, {timeZone}); + }, "Time zone: " + timeZone); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js index 0fcce4ac7e..3c5608d162 100644 --- a/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js +++ b/js/src/tests/test262/intl402/DisplayNames/prototype/of/type-region-invalid.js @@ -14,7 +14,7 @@ features: [Intl.DisplayNames] ---*/ // https://unicode.org/reports/tr35/#unicode_region_subtag -// unicode_region_subtag = (alpha{2} | digit{3}) ; +// unicode_region_subtag = (alpha{2} | digit{3}) ; var displayNames = new Intl.DisplayNames(undefined, {type: 'region'}); diff --git a/js/src/tests/test262/intl402/DurationFormat/constructor-unit-style-defaults.js b/js/src/tests/test262/intl402/DurationFormat/constructor-unit-style-defaults.js new file mode 100644 index 0000000000..93f54dcab4 --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/constructor-unit-style-defaults.js @@ -0,0 +1,34 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat +description: Verifies that default style settings for units following units with "numeric" or "2-digit" style are honored. +info: | + GetDurationUnitOptions (unit, options, baseStyle, stylesList, digitalBase, prevStyle) + (...) + 3. If style is undefined, then + (...) + i. If prevStyle is "fractional", "numeric" or "2-digit", then + (...) + 2. Set style to "numeric". + (...) + 9. If prevStyle is "numeric" or "2-digit", then + (...) + b. If unit is "minutes" or "seconds", then + i. Set style to "2-digit". +features: [Intl.DurationFormat] +---*/ + +for (const numericLikeStyle of ["numeric", "2-digit"]){ + var opts = new Intl.DurationFormat([], {hours: numericLikeStyle}).resolvedOptions(); + + assert.sameValue(opts.minutes, "2-digit", `minutes default value should be '2-digit' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.seconds, "2-digit", `seconds default value should be '2-digit' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.milliseconds, "numeric", `milliseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.microseconds, "numeric", `microseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); + assert.sameValue(opts.nanoseconds, "numeric", `nanoseconds default value should be 'numeric' when following any ${numericLikeStyle}-styled unit`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/fractions-of-subsecond-units-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/fractions-of-subsecond-units-en.js new file mode 100644 index 0000000000..342fa613cf --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/fractions-of-subsecond-units-en.js @@ -0,0 +1,65 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Checks that fractional milliseconds and microseconds are formatted correctly when microseconds or nanoseconds are the first units with "numeric" style. +info: | + PartitionDurationFormatPattern ( durationFormat, duration ) + (...) + 9. + (...) + g. If unit is "seconds", "milliseconds", or "microseconds", then + i. If unit is "seconds", then + 1. Let nextStyle be durationFormat.[[MillisecondsStyle]]. + ii. Else if unit is "milliseconds", then + 1. Let nextStyle be durationFormat.[[MicrosecondsStyle]]. + iii. Else, + 1. Let nextStyle be durationFormat.[[NanosecondsStyle]]. + iv. If nextStyle is "fractional", then + 1. Set value to value + AddFractionalDigits(durationFormat, duration). + 2. If durationFormat.[[FractionalDigits]] is undefined, then + a. Let maximumFractionDigits be 9𝔽. + b. Let minimumFractionDigits be +0𝔽. + 3. Else, + a. Let maximumFractionDigits be 𝔽(durationFormat.[[FractionalDigits]]). + b. Let minimumFractionDigits be 𝔽(durationFormat.[[FractionalDigits]]). + 4. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", maximumFractionDigits ). + 5. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", minimumFractionDigits ). + 6. Perform ! CreateDataPropertyOrThrow(nfOpts, "roundingMode", "trunc"). + 7. Set done to true. + +locale: [en] +features: [Intl.DurationFormat] +---*/ + + +const locale = "en"; +const decimalSeparator = "."; + +let d = {seconds: 3, milliseconds: 444, microseconds: 55, nanoseconds: 6}; +let dfOpts = {microseconds: "numeric"}; + +let expectedList = []; +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "second", unitDisplay: "short"}).format(d.seconds)); +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "millisecond", unitDisplay: "short", minimumFractionDigits:0, maximumFractionDigits: 9}).format(d.milliseconds.toString() + decimalSeparator + d.microseconds.toString().padStart(3, '0') + d.nanoseconds.toString().padStart(3, '0'))); + +let expected = new Intl.ListFormat(locale, {style: "short"}).format(expectedList); +let actual = new Intl.DurationFormat(locale, dfOpts).format(d); + +// assert.sameValue(actual, expected, `DurationFormat output when microseconds first "numeric" unit`); + +dfOpts = {nanoseconds: "numeric"}; +expectedList = []; + +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "second", unitDisplay: "short"}).format(d.seconds)); +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "millisecond", unitDisplay: "short"}).format(d.milliseconds)); +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "microsecond", unitDisplay: "short", minimumFractionDigits:0, maximumFractionDigits: 9}).format(d.microseconds.toString() + decimalSeparator + d.nanoseconds.toString().padStart(3, '0'))); + +expected = new Intl.ListFormat(locale, {style: "short"}).format(expectedList); +actual = new Intl.DurationFormat(locale, dfOpts).format(d); + +assert.sameValue(actual, expected, `DurationFormat output when nanoseconds first "numeric" unit`); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-non-numeric-styles-es.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-non-numeric-styles-es.js new file mode 100644 index 0000000000..33ec1a2776 --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-non-numeric-styles-es.js @@ -0,0 +1,88 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Test if format method formats duration correctly with mixed non-numeric settings for unit styles. Compares output from format method to output produced through using NumberFormat and ListFormat as used by DurationFormat. +info: | + PartitionDurationFormatPattern ( durationFormat, duration ) + ... + 9. While done is false, repeat for each row in Table 2 in table order, except the header row: + ... + k. If value is not 0 or display is not "auto" or displayRequired is "true", then + ... + v. If style is not "fractional", "numeric", or "2-digit", then + 1. Perform ! CreateDataPropertyOrThrow(nfOpts, "style", "unit"). + 2. Perform ! CreateDataPropertyOrThrow(nfOpts, "unit", numberFormatUnit). + 3. Perform ! CreateDataPropertyOrThrow(nfOpts, "unitDisplay", style). + ... + ix. Let parts be ! PartitionNumberPattern(nf, value). + ... + 14. Perform ! CreateDataPropertyOrThrow(lfOpts, "style", listStyle). + 15. Let lf be ! Construct(%ListFormat%, « durationFormat.[[Locale]], lfOpts »). + ... + 18. Let formatted be CreatePartsFromList(lf, strings). + +locale: [es] +features: [Intl.DurationFormat] +---*/ + +function formatDuration(locale, duration, dfOpts){ + let result = []; + for (const unit in duration){ + let nfUnit = unit.substring(0, unit.length - 1); + let nf = new Intl.NumberFormat(locale, {style: "unit", unit: nfUnit, unitDisplay: dfOpts[unit]}); + result.push(nf.format(duration[unit])); + } + + for (const baseStyle of ["long", "short", "narrow"]){ + let lf = new Intl.ListFormat(locale, {type: "unit", style: baseStyle}); + let expected = lf.format(result); + dfOpts.style = baseStyle; + let df = new Intl.DurationFormat(locale, dfOpts); + let actual = df.format(duration); + assert.sameValue(actual, expected); + } +} + +const duration = { + years: 1, + months: 2, + weeks: 3, + days: 0, + hours: 4, + minutes: 5, + seconds: 6, + milliseconds: 7, + microseconds: 8, + nanoseconds: 9, +}; + +const locale = "es"; + +formatDuration(locale, duration, { + years: "narrow", + months: "narrow", + weeks: "narrow", + days: "short", + hours: "short", + minutes: "short", + seconds: "long", + milliseconds: "long", + microseconds: "long", + nanoseconds: "narrow", }); + +formatDuration(locale, duration, { + years: "long", + months: "short", + weeks: "narrow", + days: "long", + hours: "short", + minutes: "narrow", + seconds: "long", + milliseconds: "short", + microseconds: "narrow", + nanoseconds: "long", }); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js new file mode 100644 index 0000000000..19adbfbd47 --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/mixed-short-and-numeric.js @@ -0,0 +1,37 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-Intl.DurationFormat.prototype.format +description: Checks that durations containing a mixture of numericlike and non-numericlike styles are formatted using the "short" style when DurationFormat base style is *undefined*. +info: | + PartitionDurationFormatPattern ( durationFormat, duration ) + + 12. Let listStyle be durationFormat.[[Style]]. + (...) + 14. Perform ! CreateDataPropertyOrThrow(lfOpts, "style", listStyle). + +locale: [en] +features: [Intl.DurationFormat] +---*/ + +const locale = "en"; +const timeSeparator = ":"; + + +let d = {days: 5, hours: 1, minutes: 2, seconds: 3}; +let dfOpts = {minutes: "numeric", seconds: "numeric"}; + +let expectedList = []; +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "day", unitDisplay: "short"}).format(d.days)); +expectedList.push(new Intl.NumberFormat(locale, {style: "unit", unit: "hour", unitDisplay: "short"}).format(d.hours)); +expectedList.push(new Intl.NumberFormat(locale).format(d.minutes) + timeSeparator + new Intl.NumberFormat(locale, {minimumIntegerDigits: 2}).format(d.seconds)); + +let expected = new Intl.ListFormat(locale, {style: "short"}).format(expectedList); +let actual = new Intl.DurationFormat(locale, dfOpts).format(d); + +assert.sameValue(actual, expected); + + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-default-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-default-en.js index c6b58a5dfc..3c0f1d6dd5 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-default-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-default-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and default style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-short-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-short-en.js index 83eb5b4639..9ebf996341 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-short-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-duration-style-short-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and "short" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-digital-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-digital-en.js index c9f119c368..e26f198cd5 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-digital-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-digital-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and "digital" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-long-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-long-en.js index fe074d488e..d7654f5630 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-long-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-long-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and "long" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-narrow-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-narrow-en.js index 4d1db5dc67..1735112336 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-narrow-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/negative-durationstyle-narrow-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.format description: > Test format method with negative duration and "narrow" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js index dc5ad4ea84..3c37afa1b4 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/numeric-hour-with-zero-minutes-and-non-zero-seconds.js @@ -5,8 +5,8 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: > - The correct separator is used for numeric hours with zero minutes and non-zero seconds. -locale: [en-US] + Minutes with numeric or 2-digit style are included in the output when between displayed hours and seconds, even when the minutes value is zero. +locale: [en] features: [Intl.DurationFormat] ---*/ @@ -15,30 +15,18 @@ const df = new Intl.DurationFormat("en", { hours: "numeric", }); -const lf = new Intl.ListFormat("en", { - type: "unit", - style: "short", -}); - const duration = { hours: 1, - - // Minutes is omitted from the output when its value is zero. minutes: 0, - - // Either seconds or sub-seconds must be non-zero. seconds: 3, }; -const expected = lf.format([ - new Intl.NumberFormat("en", {minimumIntegerDigits: 1}).format(duration.hours), - new Intl.NumberFormat("en", {minimumIntegerDigits: 2}).format(duration.seconds), -]); +const expected = "1:00:03" assert.sameValue( df.format(duration), expected, - `No time separator is used when minutes is zero` + `Minutes always displayed when between displayed hours and seconds, even if minutes is 0` ); reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/precision-exact-mathematical-values.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/precision-exact-mathematical-values.js index 5518450d6a..dbb34d39f7 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/precision-exact-mathematical-values.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/precision-exact-mathematical-values.js @@ -25,7 +25,7 @@ info: | 7. Let parts be ! PartitionNumberPattern(nf, value). ... -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-default-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-default-en.js index 6eb5c4999e..dae05ae5f1 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-default-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-default-en.js @@ -5,7 +5,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-en.js index 4f34d50aa9..cc2dd3342f 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-en.js @@ -6,7 +6,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-en.js new file mode 100644 index 0000000000..60c2232d6a --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-en.js @@ -0,0 +1,51 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-partitiondurationformatpattern +description: > + Test to ensure that correct number of fractional digits is displayed if fractionalDigits is explicitly specified. + +info: | + 4. If durationFormat.[[FractionalDigits]] is undefined, then + a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9). + b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", 0). + 5. Else, + a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]). + b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", durationFormat.[[FractionalDigits]]). +locale: [en] +features: [Intl.DurationFormat] +---*/ + +const duration = { + hours: 1, + minutes: 22, + seconds: 33, + milliseconds: 111, + microseconds: 222, + nanoseconds: 333, +}; + + +const style = "digital"; +const df = new Intl.DurationFormat("en", {style, fractionalDigits: 0}); +const dfMilli = new Intl.DurationFormat("en", {style, fractionalDigits: 3}); +const dfFourDigits = new Intl.DurationFormat("en", {style, fractionalDigits: 4}); +const dfMicro = new Intl.DurationFormat("en", {style, fractionalDigits: 6}); +const dfEightDigits = new Intl.DurationFormat("en", {style, fractionalDigits: 8}); +const dfNano = new Intl.DurationFormat("en", {style, fractionalDigits: 9}); + +assert.sameValue(df.format(duration), "1:22:33", `format output without sub-second digits using ${style} style option`); + +assert.sameValue(dfMilli.format(duration), "1:22:33.111", `format output with sub-second digits and fractionalDigits: 3 using ${style} style option`); + +assert.sameValue(dfFourDigits.format(duration), "1:22:33.1112", `format output with sub-second digits and fractionalDigits: 4 using ${style} style option`); + +assert.sameValue(dfMicro.format(duration), "1:22:33.111222", `format output with sub-second digits and fractionalDigits: 6 using ${style} style option`); + +assert.sameValue(dfEightDigits.format(duration), "1:22:33.11122233", `format output with sub-second digits and fractionalDigits: 8 using ${style} style option`); + +assert.sameValue(dfNano.format(duration), "1:22:33.111222333", `format output with sub-second digits and fractionalDigits: 9 using ${style} style option`); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined-en.js new file mode 100644 index 0000000000..b297c0c7ba --- /dev/null +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined-en.js @@ -0,0 +1,80 @@ +// |reftest| skip -- Intl.DurationFormat is not supported +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-partitiondurationformatpattern +description: > + Test to ensure that correct number of fractional digits is displayed (i.e. however many are necessary to represent the data fully) if the fractionalDigits option is left *undefined* + +info: | + 4. If durationFormat.[[FractionalDigits]] is undefined, then + a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9). + b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", 0). + 5. Else, + a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]). + b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", durationFormat.[[FractionalDigits]]). +locale: [en] +features: [Intl.DurationFormat] +---*/ + + +const durationNano = { + hours: 1, + minutes: 22, + seconds: 33, + milliseconds: 111, + microseconds: 222, + nanoseconds: 333 +}; + +const durationMicro = { + hours: 1, + minutes: 22, + seconds: 33, + milliseconds: 111, + microseconds: 222 +}; + +const durationMilli = { + hours: 1, + minutes: 22, + seconds: 33, + milliseconds: 111 +}; + +const durationNoSubsecond = { + hours: 1, + minutes: 22, + seconds: 33 +}; + +const durationFiveFractional = { + hours: 2, + minutes: 30, + seconds: 10, + milliseconds: 111, + microseconds: 220, +}; + +const durationSevenFractional = { + hours: 2, + minutes: 30, + seconds: 10, + milliseconds: 111, + microseconds: 220, + nanoseconds: 300 +}; + +const style = "digital"; +const df = new Intl.DurationFormat("en", {style, fractionalDigits: undefined}); + +assert.sameValue(df.format(durationNano), "1:22:33.111222333", `format output with nanosecond digits and fractionalDigits: undefined using ${style} style option`); +assert.sameValue(df.format(durationMicro), "1:22:33.111222", `format output with microsecond digits and fractionalDigits: undefined using ${style} style option`); +assert.sameValue(df.format(durationMilli), "1:22:33.111", `format output with millisecond digits and fractionalDigits: undefined using ${style} style option`); +assert.sameValue(df.format(durationNoSubsecond), "1:22:33", `format output with no subsecond digits and fractionalDigits: undefined using ${style} style option`); + +assert.sameValue(df.format(durationFiveFractional), "2:30:10.11122", `format output with five subsecond digits and fractionalDigits: undefined using ${style} style option`); +assert.sameValue(df.format(durationSevenFractional), "2:30:10.1112203", `format output with seven subsecond digits and fractionalDigits: undefined using ${style} style option`); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined.js deleted file mode 100644 index 631e6c36eb..0000000000 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits-undefined.js +++ /dev/null @@ -1,71 +0,0 @@ -// |reftest| skip -- Intl.DurationFormat is not supported -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-partitiondurationformatpattern -description: > - Test to ensure that correct number of fractional digits is displayed (i.e. however many are necessary to represent the data fully) if the fractionalDigits option is left *undefined* - -info: | - 4. If durationFormat.[[FractionalDigits]] is undefined, then - a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9). - b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", 0). - 5. Else, - a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]). - b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", durationFormat.[[FractionalDigits]]). -features: [Intl.DurationFormat] ----*/ - - -const durationNano = { - hours: 1, - minutes: 22, - seconds: 33, - milliseconds: 111, - microseconds: 222, - nanoseconds: 333 -}; - -const durationMicro = { - hours: 1, - minutes: 22, - seconds: 33, - milliseconds: 111, - microseconds: 222 -}; - -const durationMill = { - hours: 1, - minutes: 22, - seconds: 33, - milliseconds: 111 -}; - -const durationNoSubsecond = { - hours: 1, - minutes: 22, - seconds: 33 -}; - -const durationSevenFractional = { - hours: 2, - minutes: 30, - seconds: 10, - milliseconds: 111, - microseconds: 220, - nanoseconds: 300 -}; - -const style = "digital"; -const df = new Intl.DurationFormat(undefined, {style, fractionalDigits: undefined}); - -assert.sameValue(df.format(durationNano), "1:22:33.111222333", `format output with nanosecond digits and fractionalDigits: undefined using ${style} style option`); -assert.sameValue(df.format(durationMicro), "1:22:33.111222", `format output with microsecond digits and fractionalDigits: undefined using ${style} style option`); -assert.sameValue(df.format(durationMilli), "1:22:33.111", `format output with millisecond digits and fractionalDigits: undefined using ${style} style option`); -assert.sameValue(df.format(durationNoSubsecond), "1:22:33", `format output with no subsecond digits and fractionalDigits: undefined using ${style} style option`); - -assert.sameValue(df.format(durationFiveFractional), "2:30:11122", `format output with five subsecond digits and fractionalDigits: undefined using ${style} style option`); -assert.sameValue(df.format(durationSevenFractional), "2:30:1112203", `format output with seven subsecond digits and fractionalDigits: undefined using ${style} style option`); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits.js deleted file mode 100644 index d75f51b14a..0000000000 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-digital-fractionalDigits.js +++ /dev/null @@ -1,50 +0,0 @@ -// |reftest| skip -- Intl.DurationFormat is not supported -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-partitiondurationformatpattern -description: > - Test to ensure that correct number of fractional digits is displayed if fractionalDigits is explicitly specified. - -info: | - 4. If durationFormat.[[FractionalDigits]] is undefined, then - a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", 9). - b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", 0). - 5. Else, - a. Perform ! CreateDataPropertyOrThrow(nfOpts, "maximumFractionDigits", durationFormat.[[FractionalDigits]]). - b. Perform ! CreateDataPropertyOrThrow(nfOpts, "minimumFractionDigits", durationFormat.[[FractionalDigits]]). -features: [Intl.DurationFormat] ----*/ - -const duration = { - hours: 1, - minutes: 22, - seconds: 33, - milliseconds: 111, - microseconds: 222, - nanoseconds: 333, -}; - - -const style = "digital"; -const df = new Intl.DurationFormat(undefined, {style, fractionalDigits: 0}); -const dfMilli = new Intl.DurationFormat(undefined, {style, fractionalDigits: 3}); -const dfFourDigits = new Intl.DurationFormat(undefined, {style, fractionalDigits: 4}); -const dfMicro = new Intl.DurationFormat(undefined, {style, fractionalDigits: 6}); -const dfEightDigits = new Intl.DurationFormat(undefined, {style, fractionalDigits: 8}); -const dfNano = new Intl.DurationFormat(undefined, {style, fractionalDigits: 9}); - -assert.sameValue(df.format(duration), "1:22:33", `format output without sub-second digits using ${style} style option`); - -assert.sameValue(dfMilli.format(duration), "1:22:33.111", `format output with sub-second digits and fractionalDigits: 3 using ${style} style option`); - -assert.sameValue(dfFourDigits.format(duration), "1:22:33.1112", `format output with sub-second digits and fractionalDigits: 4 using ${style} style option`); - -assert.sameValue(dfMicro.format(duration), "1:22:33.111222", `format output with sub-second digits and fractionalDigits: 6 using ${style} style option`); - -assert.sameValue(dfEightDigits.format(duration), "1:22:33.11122233", `format output with sub-second digits and fractionalDigits: 8 using ${style} style option`); - -assert.sameValue(dfNano.format(duration), "1:22:33.111222333", `format output with sub-second digits and fractionalDigits: 9 using ${style} style option`); - -reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-long-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-long-en.js index d9e6fc6cbb..74524da674 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-long-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-long-en.js @@ -5,7 +5,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-narrow-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-narrow-en.js index 66b2258761..e75dc17170 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-narrow-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-narrow-en.js @@ -5,7 +5,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-short-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-short-en.js index 2a66c01b06..049e034681 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-short-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/format/style-short-en.js @@ -5,7 +5,7 @@ /*--- esid: sec-Intl.DurationFormat.prototype.format description: Test if format method formats duration correctly with different "style" arguments -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js index bfc182c34b..5ce6300268 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-default-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and default style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-digital-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-digital-en.js index 52a40072ba..6978739ac3 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-digital-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-digital-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and "digital" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-long-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-long-en.js index 3756db8a84..638f5922f1 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-long-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-long-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and "long" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-narrow-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-narrow-en.js index a9717ce67a..b138100f8a 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-narrow-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-narrow-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and "narrow" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-short-en.js b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-short-en.js index bc2ed69c5b..76ce8ccbf1 100644 --- a/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-short-en.js +++ b/js/src/tests/test262/intl402/DurationFormat/prototype/formatToParts/negative-duration-formatToParts-style-short-en.js @@ -6,7 +6,7 @@ esid: sec-Intl.DurationFormat.prototype.formatToParts description: > Test formatToParts method with negative duration and "short" style -locale: [en-US] +locale: [en] includes: [testIntl.js] features: [Intl.DurationFormat] ---*/ diff --git a/js/src/tests/test262/intl402/Locale/constructor-options-collation-invalid.js b/js/src/tests/test262/intl402/Locale/constructor-options-collation-invalid.js index d256093257..10f5cd5e4a 100644 --- a/js/src/tests/test262/intl402/Locale/constructor-options-collation-invalid.js +++ b/js/src/tests/test262/intl402/Locale/constructor-options-collation-invalid.js @@ -30,7 +30,7 @@ const invalidCollationOptions = [ for (const invalidCollationOption of invalidCollationOptions) { assert.throws(RangeError, function() { new Intl.Locale("en", {collation: invalidCollationOption}); - }, '`new Intl.Locale("en", {collation: invalidCollationOption})` throws RangeError'); + }); } reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Locale/prototype/calendar/canonicalize.js b/js/src/tests/test262/intl402/Locale/prototype/calendar/canonicalize.js new file mode 100644 index 0000000000..5ade4fe795 --- /dev/null +++ b/js/src/tests/test262/intl402/Locale/prototype/calendar/canonicalize.js @@ -0,0 +1,22 @@ +// Copyright 2024 Google Inc. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-apply-unicode-extension-to-tag +description: Checks canonicalize value of extension in ApplyUnicodeExtensionToTag. +info: | + ApplyUnicodeExtensionToTag + 1. Let _optionsUValue_ be the ASCII-lowercase of _optionsValue_. + 1. Set _value_ to the String value resulting from canonicalizing _optionsUValue_ as a value of key _key_ per Unicode Technical Standard #35 Part 1 Core, Annex C LocaleId Canonicalization Section 5 Canonicalizing Syntax, Processing LocaleIds. +features: [Intl.Locale] +---*/ + +const loc = new Intl.Locale('en', {calendar: 'islamicc'}); + +assert.sameValue(loc.toString(), "en-u-ca-islamic-civil", + "'islamicc' should be canonicalize to 'islamic-civil'"); + +assert.sameValue(loc.calendar, "islamic-civil", + "'islamicc' should be canonicalize to 'islamic-civil'"); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateAdd/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateAdd/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateAdd/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateAdd/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateFromFields/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateFromFields/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateFromFields/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateFromFields/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateUntil/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateUntil/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateUntil/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dateUntil/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/day/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/day/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/day/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/day/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfWeek/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfWeek/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfWeek/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/dayOfYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInMonth/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInMonth/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInMonth/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInMonth/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInWeek/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInWeek/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInWeek/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInWeek/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/daysInYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..2772960abe --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.era +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.era(arg); + assert.sameValue(result, undefined, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js index d0698c070c..57df6364f9 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.era(arg), diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..f34a405169 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.era +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.era(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/shell.js index 32df7c4217..63bc783738 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/era/shell.js @@ -2046,6 +2046,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2133,6 +2136,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js new file mode 100644 index 0000000000..2899ea877c --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js @@ -0,0 +1,28 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.erayear +description: An ISO 8601 string can be converted to a calendar ID in Calendar +features: [Temporal] +---*/ + +const instance = new Temporal.Calendar("iso8601"); + +for (const calendar of [ + "2020-01-01", + "2020-01-01[u-ca=iso8601]", + "2020-01-01T00:00:00.000000000", + "2020-01-01T00:00:00.000000000[u-ca=iso8601]", + "01-01", + "01-01[u-ca=iso8601]", + "2020-01", + "2020-01[u-ca=iso8601]", +]) { + const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; + const result = instance.eraYear(arg); + assert.sameValue(result, undefined, `Calendar created from string "${calendar}"`); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js index 65675a5894..eaa93d916a 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js @@ -16,7 +16,8 @@ const invalidStrings = [ "-000000-10-31T17:45+00:00[UTC]", ]; const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { +invalidStrings.forEach((str) => { + const arg = { year: 1976, month: 11, day: 18, calendar: str }; assert.throws( RangeError, () => instance.eraYear(arg), diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js new file mode 100644 index 0000000000..7bec3d6a54 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.erayear +description: Annotation keys are lowercase-only +features: [Temporal] +---*/ + +const invalidStrings = [ + ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], + ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], + ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], +]; +const instance = new Temporal.Calendar("iso8601"); +invalidStrings.forEach(([arg, descr]) => { + assert.throws( + RangeError, + () => instance.eraYear(arg), + `annotation keys must be lowercase: ${arg} - ${descr}` + ); +}); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/shell.js index 32df7c4217..63bc783738 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/eraYear/shell.js @@ -2046,6 +2046,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2133,6 +2136,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/inLeapYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/inLeapYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/inLeapYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/inLeapYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/month/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/month/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/month/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/month/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthCode/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthCode/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthCode/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthCode/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthDayFromFields/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthDayFromFields/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthDayFromFields/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthDayFromFields/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthsInYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthsInYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthsInYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/monthsInYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..3eeb8186ef --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.weekofyear +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = { month: 1, day: 1, year: 2021, calendar}; + +assert.sameValue(calendar.weekOfYear({...date}), 1); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = { month: 1, day: 1, year: 2021, calendar}; + +assert.sameValue(calendar.weekOfYear({...isodate}), 53); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js new file mode 100644 index 0000000000..9392c0c13b --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.weekofyear +description: > + Temporal.Calendar.prototype.weekOfYear returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = { month: 1, day: 1, year: 2024, calendar}; + +assert.sameValue(calendar.weekOfYear({...date}), 1); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = { month: 1, day: 1, year: 2024, calendar}; + +assert.sameValue(calendar.weekOfYear({...nonisodate}), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/weekOfYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/year/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/year/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/year/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/year/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearMonthFromFields/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearMonthFromFields/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearMonthFromFields/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearMonthFromFields/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..ff2d9c0b60 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearofweek +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = { month: 1, day: 1, year: 2021, calendar}; + +assert.sameValue(calendar.yearOfWeek({...date}), 2021); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = { month: 1, day: 1, year: 2021, calendar}; + +assert.sameValue(calendar.yearOfWeek({...isodate}), 2020); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js new file mode 100644 index 0000000000..9abf674f0f --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearofweek +description: > + Temporal.Calendar.prototype.yearOfWeek returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = { month: 1, day: 1, year: 2024, calendar}; + +assert.sameValue(calendar.yearOfWeek({...date}), 2024); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = { month: 1, day: 1, year: 2024, calendar}; + +assert.sameValue(calendar.yearOfWeek({...nonisodate}), undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Calendar/prototype/yearOfWeek/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Duration/prototype/add/shell.js b/js/src/tests/test262/intl402/Temporal/Duration/prototype/add/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Duration/prototype/add/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Duration/prototype/add/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Duration/prototype/round/shell.js b/js/src/tests/test262/intl402/Temporal/Duration/prototype/round/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Duration/prototype/round/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Duration/prototype/round/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Duration/prototype/subtract/shell.js b/js/src/tests/test262/intl402/Temporal/Duration/prototype/subtract/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Duration/prototype/subtract/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Duration/prototype/subtract/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Duration/prototype/total/shell.js b/js/src/tests/test262/intl402/Temporal/Duration/prototype/total/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/Duration/prototype/total/shell.js +++ b/js/src/tests/test262/intl402/Temporal/Duration/prototype/total/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..2d0614deb9 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/Instant/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,31 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.instant.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const instant = new Temporal.Instant(1711475200_000_000_000n); + +assert( + instant.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !instant.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); +assert( + instant.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !instant.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/compare/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/compare/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/compare/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/compare/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/from/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/since/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/since/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/since/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/since/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..0bb42308d5 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = new Temporal.PlainDate(2024, 3, 26, "gregory"); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = new Temporal.PlainDate(2024, 3, 26, "islamic"); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/until/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/until/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/until/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/until/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/browser.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..312d87afd6 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.weekofyear +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDate(2021, 1, 1, calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.PlainDate(2021, 1, 1, calendar); + +assert.sameValue(isodate.weekOfYear, 53); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js new file mode 100644 index 0000000000..b9717b8eba --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.weekofyear +description: > + Temporal.PlainDate.prototype.weekOfYear returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDate(2024, 1, 1, calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar); + +assert.sameValue(nonisodate.weekOfYear, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/weekOfYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/browser.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..d8556f309a --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.yearofweek +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDate(2021, 1, 1, calendar); + +assert.sameValue(date.yearOfWeek, 2021); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.PlainDate(2021, 1, 1, calendar); + +assert.sameValue(isodate.yearOfWeek, 2020); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js new file mode 100644 index 0000000000..047166e765 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.yearofweek +description: > + Temporal.PlainDate.prototype.yearOfWeek returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDate(2024, 1, 1, calendar); + +assert.sameValue(date.yearOfWeek, 2024); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar); + +assert.sameValue(nonisodate.yearOfWeek, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDate/prototype/yearOfWeek/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/compare/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/compare/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/compare/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/compare/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/from/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/since/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/since/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/since/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/since/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..9abc7e4128 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = new Temporal.PlainDateTime(2024, 3, 26, 10, 30, 0, 0, 0, 0, "gregory"); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = new Temporal.PlainDateTime(2024, 3, 26, 10, 30, 0, 0, 0, 0, "islamic"); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/until/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/until/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/until/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/until/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/browser.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..5b0fce3473 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.weekofyear +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(isodate.weekOfYear, 53); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js new file mode 100644 index 0000000000..b90a9cde8d --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.weekofyear +description: > + Temporal.PlainDateTime.prototype.weekOfYear returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(nonisodate.weekOfYear, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/weekOfYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/withPlainDate/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/browser.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..a3846e5d01 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.yearofweek +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(date.yearOfWeek, 2021); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(isodate.yearOfWeek, 2020); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js new file mode 100644 index 0000000000..cffb030267 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js @@ -0,0 +1,25 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.yearofweek +description: > + Temporal.PlainDateTime.prototype.yearOfWeek returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(date.yearOfWeek, 2024); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); + +assert.sameValue(nonisodate.yearOfWeek, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/from/shell.js b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..9011393592 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = Temporal.PlainMonthDay.from({ monthCode: "M03", day: 26, calendar: "gregory" }); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = Temporal.PlainMonthDay.from({ monthCode: "M09", day: 16, calendar: "islamic" }); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toPlainDate/shell.js b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toPlainDate/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toPlainDate/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainMonthDay/prototype/toPlainDate/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toPlainDateTime/shell.js b/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toPlainDateTime/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toPlainDateTime/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toPlainDateTime/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toZonedDateTime/shell.js b/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toZonedDateTime/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toZonedDateTime/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainTime/prototype/toZonedDateTime/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/compare/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/compare/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/compare/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/compare/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/from/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/since/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/since/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/since/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/since/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..b4816e1b19 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = Temporal.PlainYearMonth.from({ year: 2024, monthCode: "M03", calendar: "gregory" }); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = Temporal.PlainYearMonth.from({ year: 1445, monthCode: "M09", calendar: "islamic" }); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/until/shell.js b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/until/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/until/shell.js +++ b/js/src/tests/test262/intl402/Temporal/PlainYearMonth/prototype/until/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js b/js/src/tests/test262/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js new file mode 100644 index 0000000000..90f7e9f4f6 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js @@ -0,0 +1,47 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone.from +description: Only IANA time zone identifiers are allowed. +features: [Temporal] +---*/ + +// List of non-IANA link names, copied from: +// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones +const invalidTimeZones = [ + "ACT", + "AET", + "AGT", + "ART", + "AST", + "BET", + "BST", + "CAT", + "CNT", + "CST", + "CTT", + "EAT", + "ECT", + "IET", + "IST", + "JST", + "MIT", + "NET", + "NST", + "PLT", + "PNT", + "PRT", + "PST", + "SST", + "VST", +]; + +for (let timeZone of invalidTimeZones) { + assert.throws(RangeError, () => { + Temporal.TimeZone.from(timeZone); + }, "Time zone: " + timeZone); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/legacy-non-iana.js b/js/src/tests/test262/intl402/Temporal/TimeZone/legacy-non-iana.js new file mode 100644 index 0000000000..aaf9dd1a80 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/legacy-non-iana.js @@ -0,0 +1,47 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.timezone +description: Only IANA time zone identifiers are allowed. +features: [Temporal] +---*/ + +// List of non-IANA link names, copied from: +// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones +const invalidTimeZones = [ + "ACT", + "AET", + "AGT", + "ART", + "AST", + "BET", + "BST", + "CAT", + "CNT", + "CST", + "CTT", + "EAT", + "ECT", + "IET", + "IST", + "JST", + "MIT", + "NET", + "NST", + "PLT", + "PNT", + "PRT", + "PST", + "SST", + "VST", +]; + +for (let timeZone of invalidTimeZones) { + assert.throws(RangeError, () => { + new Temporal.TimeZone(timeZone); + }, "Time zone: " + timeZone); +} + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getInstantFor/shell.js b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getInstantFor/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getInstantFor/shell.js +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getInstantFor/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/shell.js b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/shell.js +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/shell.js b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/shell.js +++ b/js/src/tests/test262/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/compare/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/compare/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/compare/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/compare/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/from/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/from/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/from/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/from/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/equals/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/equals/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/equals/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/equals/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/era/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/era/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/era/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/era/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/eraYear/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/eraYear/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/eraYear/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/eraYear/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/since/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/since/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/since/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/since/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js new file mode 100644 index 0000000000..b8235d824d --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/dateStyle.js @@ -0,0 +1,34 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tolocalestring +description: Basic tests that dateStyle option affects output +locale: [en-u-ca-gregory, en-u-ca-islamic] +features: [Temporal, Intl.DateTimeFormat-datetimestyle] +---*/ + +const dateGregorian = new Temporal.ZonedDateTime(1711475200_000_000_000n, "UTC", "gregory"); + +assert( + dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "long" }).includes("March"), + "dateStyle: long writes month of March out in full" +); +assert( + !dateGregorian.toLocaleString("en-u-ca-gregory", { dateStyle: "short" }).includes("March"), + "dateStyle: short does not write month of March out in full" +); + +const dateIslamic = new Temporal.ZonedDateTime(1711475200_000_000_000n, "UTC", "islamic"); + +assert( + dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "long" }).includes("Ramadan"), + "dateStyle: long writes month of Ramadan out in full" +); +assert( + !dateIslamic.toLocaleString("en-u-ca-islamic", { dateStyle: "short" }).includes("Ramadan"), + "dateStyle: short does not write month of Ramadan out in full" +); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/until/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/until/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/until/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/until/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/browser.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..bf1ddaaaeb --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.weekofyear +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); + +assert.sameValue(isodate.weekOfYear, 53); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js new file mode 100644 index 0000000000..79769e6d19 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.weekofyear +description: > + Temporal.ZonedDateTime.prototype.weekOfYear returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); + +// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); +const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); + +assert.sameValue(date.weekOfYear, 1); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); + +assert.sameValue(nonisodate.weekOfYear, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/with/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/with/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/with/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/with/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/shell.js +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/withPlainDate/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/browser.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/browser.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js new file mode 100644 index 0000000000..afa4ce7165 --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -0,0 +1,30 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.yearofweek +description: > + In the ISO 8601 week calendar, calendar week number 1 of a calendar year is + the week including the first Thursday of that year (based on the principle + that a week belongs to the same calendar year as the majority of its calendar + days). Because of this, some calendar days of the first calendar week of a + calendar year may be part of the preceding date calendar year, and some + calendar days of the last calendar week of a calendar year may be part of + the next calendar year. +features: [Temporal] +---*/ + +// + +let calendar = new Temporal.Calendar("gregory"); +const date = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); + +assert.sameValue(date.yearOfWeek, 2021); + +calendar = new Temporal.Calendar("iso8601"); +const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); + +assert.sameValue(isodate.yearOfWeek, 2020); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js new file mode 100644 index 0000000000..58f0b6a5ff --- /dev/null +++ b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js @@ -0,0 +1,27 @@ +// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.yearofweek +description: > + Temporal.ZonedDateTime.prototype.yearOfWeek returns undefined for all + non-ISO calendars without a well-defined week numbering system. +features: [Temporal] +---*/ + +// Gregorian calendar has a well defined week-numbering system. + +let calendar = new Temporal.Calendar("gregory"); + +// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); +const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); + +assert.sameValue(date.yearOfWeek, 2024); + +calendar = new Temporal.Calendar("hebrew"); +const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); + +assert.sameValue(nonisodate.yearOfWeek, undefined); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/shell.js b/js/src/tests/test262/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/shell.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/js/src/tests/test262/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js b/js/src/tests/test262/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js index c6b895e5db..133d6bb5d7 100644 --- a/js/src/tests/test262/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js +++ b/js/src/tests/test262/intl402/TypedArray/prototype/toLocaleString/calls-toLocaleString-number-elements.js @@ -1,3 +1,4 @@ +// |reftest| shell-option(--enable-float16array) // Copyright (C) 2018 André Bargull. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. -- cgit v1.2.3