diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/non262/Intl/DateTimeFormat/formatRange-matches-format-output.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/src/tests/non262/Intl/DateTimeFormat/formatRange-matches-format-output.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/js/src/tests/non262/Intl/DateTimeFormat/formatRange-matches-format-output.js b/js/src/tests/non262/Intl/DateTimeFormat/formatRange-matches-format-output.js new file mode 100644 index 0000000000..67cebd1843 --- /dev/null +++ b/js/src/tests/non262/Intl/DateTimeFormat/formatRange-matches-format-output.js @@ -0,0 +1,58 @@ +// |reftest| skip-if(!this.hasOwnProperty("Intl")) + +// formatRange() returns the same output as format() when the date-time difference between +// the start and end date is too small. + +// Test case when skeleton can't be retrieved from resolved pattern (bug 1298794). +// - Best-fit pattern for the skeleton "MMMMMdd" is "M月dd日". +// - Best-fit pattern for the skeleton "Mdd" is "M/dd". +// +// So in both cases the skeleton characters in the pattern are "Mdd", which means we can't +// retrieve the original input skeleton by simply inspecting the resolved pattern. +// +// Also see: https://unicode-org.atlassian.net/browse/ICU-13518 +{ + let dtf = new Intl.DateTimeFormat("zh", {month: "narrow", day: "2-digit", timeZone: "UTC"}); + assertEq(dtf.formatRange(0, 0), dtf.format(0)); +} + +// Test that date-/time-style leads to the same output. +// ICU bug: https://unicode-org.atlassian.net/browse/ICU-20710 +{ + let dtf = new Intl.DateTimeFormat("en", {dateStyle: "full", timeStyle: "full"}); + assertEq(dtf.formatRange(0, 0), dtf.format(0)); +} + +// Test that the hourCycle option is correctly processed (test with h24). +// ICU bug: https://unicode-org.atlassian.net/browse/ICU-20707 +{ + let dtf = new Intl.DateTimeFormat("en-u-hc-h24", {hour: "2-digit", timeZone:"UTC"}); + assertEq(dtf.formatRange(0, 0), dtf.format(0)); +} +{ + let dtf = new Intl.DateTimeFormat("en", {hourCycle: "h24", hour: "2-digit", timeZone:"UTC"}); + assertEq(dtf.formatRange(0, 0), dtf.format(0)); +} + +// Test that the hourCycle option is correctly processed (test with h11). +// ICU bug: https://unicode-org.atlassian.net/browse/ICU-20707 +{ + let dt = 60 * 60 * 1000; // one hour + let dtf = new Intl.DateTimeFormat("en-u-hc-h11", {hour: "2-digit", timeZone:"UTC"}); + assertEq(dtf.formatRange(dt, dt), dtf.format(dt)); +} +{ + let dt = 60 * 60 * 1000; // one hour + let dtf = new Intl.DateTimeFormat("en", {hourCycle: "h11", hour: "2-digit", timeZone:"UTC"}); + assertEq(dtf.formatRange(dt, dt), dtf.format(dt)); +} + +// Test that non-default calendars work correctly. +// ICU bug: https://unicode-org.atlassian.net/browse/ICU-20706 +{ + let dtf = new Intl.DateTimeFormat("en-001-u-ca-hebrew"); + assertEq(dtf.formatRange(0, 0), dtf.format(0)); +} + +if (typeof reportCompare === "function") + reportCompare(0, 0); |