LibJS: Ensure tests using the "ar" locale use the "arab" number system

In ICU 76, the default was changed from "arab" to "latn". See:
c149724509

The whole point of these tests was to use a non-Latin numbering system.
This patch ensures that is the case to make following patches easier to
grok.
This commit is contained in:
Timothy Flynn 2025-01-18 13:27:07 -05:00 committed by Tim Flynn
commit 0763997591
Notes: github-actions[bot] 2025-01-18 22:57:49 +00:00
11 changed files with 286 additions and 179 deletions

View file

@ -111,7 +111,10 @@ describe("dateStyle", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", { dateStyle: d.date, timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
dateStyle: d.date,
timeZone: "UTC",
});
expect(ar.format(d0)).toBe(d.ar0);
expect(ar.format(d1)).toBe(d.ar1);
});
@ -133,7 +136,10 @@ describe("timeStyle", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", { timeStyle: d.time, timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
timeStyle: d.time,
timeZone: "UTC",
});
expect(ar.format(d0)).toBe(d.ar0);
expect(ar.format(d1)).toBe(d.ar1);
});
@ -170,7 +176,7 @@ describe("dateStyle + timeStyle", () => {
});
expect(en.format(d0)).toBe(d.en);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
dateStyle: d.date,
timeStyle: d.time,
timeZone: "UTC",
@ -194,7 +200,10 @@ describe("weekday", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", { weekday: d.weekday, timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
weekday: d.weekday,
timeZone: "UTC",
});
expect(ar.format(d0)).toBe(d.ar0);
expect(ar.format(d1)).toBe(d.ar1);
});
@ -215,7 +224,7 @@ describe("era", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", { era: d.era, timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { era: d.era, timeZone: "UTC" });
expect(ar.format(d0)).toBe(d.ar0);
expect(ar.format(d1)).toBe(d.ar1);
});
@ -228,7 +237,7 @@ describe("era", () => {
const en = new Intl.DateTimeFormat("en", { era: "short", timeZone: "UTC" });
expect(en.format(year1BC)).toBe("1/1/1 BC");
const ar = new Intl.DateTimeFormat("ar", { era: "short", timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { era: "short", timeZone: "UTC" });
expect(ar.format(year1BC)).toBe("٠١-٠١-١ ق.م");
});
});
@ -246,7 +255,7 @@ describe("year", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", { year: d.year, timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { year: d.year, timeZone: "UTC" });
expect(ar.format(d0)).toBe(d.ar0);
expect(ar.format(d1)).toBe(d.ar1);
});
@ -269,7 +278,7 @@ describe("month", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", { month: d.month, timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { month: d.month, timeZone: "UTC" });
expect(ar.format(d0)).toBe(d.ar0);
expect(ar.format(d1)).toBe(d.ar1);
});
@ -289,7 +298,7 @@ describe("day", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", { day: d.day, timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { day: d.day, timeZone: "UTC" });
expect(ar.format(d0)).toBe(d.ar0);
expect(ar.format(d1)).toBe(d.ar1);
});
@ -314,7 +323,7 @@ describe("dayPeriod", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
dayPeriod: d.dayPeriod,
hour: "numeric",
timeZone: "UTC",
@ -377,7 +386,7 @@ describe("dayPeriod", () => {
expect(en.format(date2)).toBe(d.en2);
expect(en.format(date3)).toBe(d.en3);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
hour: "numeric",
dayPeriod: "short",
timeZone: "UTC",
@ -408,7 +417,7 @@ describe("dayPeriod", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
dayPeriod: d.dayPeriod,
timeZone: "UTC",
});
@ -438,7 +447,7 @@ describe("hour", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", { hour: d.hour, timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { hour: d.hour, timeZone: "UTC" });
expect(ar.format(d0)).toBe(d.ar0);
expect(ar.format(d1)).toBe(d.ar1);
});
@ -462,7 +471,7 @@ describe("minute", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
minute: d.minute,
hour: "numeric",
timeZone: "UTC",
@ -490,7 +499,7 @@ describe("second", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
second: d.second,
minute: "numeric",
timeZone: "UTC",
@ -520,7 +529,7 @@ describe("fractionalSecondDigits", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
fractionalSecondDigits: d.fractionalSecondDigits,
second: "numeric",
minute: "numeric",
@ -587,7 +596,7 @@ describe("timeZoneName", () => {
expect(en.format(d0)).toBe(d.en0);
expect(en.format(d1)).toBe(d.en1);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
timeZone: d.timeZone,
timeZoneName: d.timeZoneName,
});
@ -607,7 +616,7 @@ describe("non-Gregorian calendars", () => {
expect(en.format(d0)).toBe("3 Tevet 5782 at 5:40:50 PM UTC");
expect(en.format(d1)).toBe("17 Shevat 5749 at 7:08:09 AM UTC");
const ar = new Intl.DateTimeFormat("ar-u-ca-hebrew", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab-ca-hebrew", {
dateStyle: "long",
timeStyle: "long",
timeZone: "UTC",

View file

@ -104,7 +104,7 @@ describe("dateStyle", () => {
{ type: "year", value: "1989" },
]);
const ar = new Intl.DateTimeFormat("ar", { dateStyle: "full", timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { dateStyle: "full", timeZone: "UTC" });
expect(ar.formatToParts(d)).toEqual([
{ type: "weekday", value: "الاثنين" },
{ type: "literal", value: "، " },
@ -126,7 +126,7 @@ describe("dateStyle", () => {
{ type: "year", value: "1989" },
]);
const ar = new Intl.DateTimeFormat("ar", { dateStyle: "long", timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { dateStyle: "long", timeZone: "UTC" });
expect(ar.formatToParts(d)).toEqual([
{ type: "day", value: "٢٣" },
{ type: "literal", value: " " },
@ -146,7 +146,10 @@ describe("dateStyle", () => {
{ type: "year", value: "1989" },
]);
const ar = new Intl.DateTimeFormat("ar", { dateStyle: "medium", timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
dateStyle: "medium",
timeZone: "UTC",
});
expect(ar.formatToParts(d)).toEqual([
{ type: "day", value: "٢٣" },
{ type: "literal", value: "/" },
@ -166,7 +169,7 @@ describe("dateStyle", () => {
{ type: "year", value: "89" },
]);
const ar = new Intl.DateTimeFormat("ar", { dateStyle: "short", timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { dateStyle: "short", timeZone: "UTC" });
expect(ar.formatToParts(d)).toEqual([
{ type: "day", value: "٢٣" },
{ type: "literal", value: "/" },
@ -192,7 +195,7 @@ describe("timeStyle", () => {
{ type: "timeZoneName", value: "Coordinated Universal Time" },
]);
const ar = new Intl.DateTimeFormat("ar", { timeStyle: "full", timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { timeStyle: "full", timeZone: "UTC" });
expect(ar.formatToParts(d)).toEqual([
{ type: "hour", value: "٧" },
{ type: "literal", value: ":" },
@ -220,7 +223,7 @@ describe("timeStyle", () => {
{ type: "timeZoneName", value: "UTC" },
]);
const ar = new Intl.DateTimeFormat("ar", { timeStyle: "long", timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { timeStyle: "long", timeZone: "UTC" });
expect(ar.formatToParts(d)).toEqual([
{ type: "hour", value: "٧" },
{ type: "literal", value: ":" },
@ -246,7 +249,10 @@ describe("timeStyle", () => {
{ type: "dayPeriod", value: "AM" },
]);
const ar = new Intl.DateTimeFormat("ar", { timeStyle: "medium", timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
timeStyle: "medium",
timeZone: "UTC",
});
expect(ar.formatToParts(d)).toEqual([
{ type: "hour", value: "٧" },
{ type: "literal", value: ":" },
@ -268,7 +274,7 @@ describe("timeStyle", () => {
{ type: "dayPeriod", value: "AM" },
]);
const ar = new Intl.DateTimeFormat("ar", { timeStyle: "short", timeZone: "UTC" });
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", { timeStyle: "short", timeZone: "UTC" });
expect(ar.formatToParts(d)).toEqual([
{ type: "hour", value: "٧" },
{ type: "literal", value: ":" },
@ -292,7 +298,7 @@ describe("special cases", () => {
{ type: "dayPeriod", value: "in the morning" },
]);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
dayPeriod: "long",
hour: "numeric",
timeZone: "UTC",
@ -319,7 +325,7 @@ describe("special cases", () => {
{ type: "fractionalSecond", value: "045" },
]);
const ar = new Intl.DateTimeFormat("ar", {
const ar = new Intl.DateTimeFormat("ar-u-nu-arab", {
fractionalSecondDigits: 3,
second: "numeric",
minute: "numeric",