diff --git a/Libraries/LibJS/Tests/builtins/Array/Array.prototype.toLocaleString.js b/Libraries/LibJS/Tests/builtins/Array/Array.prototype.toLocaleString.js index 8a39d668c58..7b0ebe82589 100644 --- a/Libraries/LibJS/Tests/builtins/Array/Array.prototype.toLocaleString.js +++ b/Libraries/LibJS/Tests/builtins/Array/Array.prototype.toLocaleString.js @@ -62,9 +62,11 @@ describe("normal behavior", () => { test("with options", () => { expect([12, 34].toLocaleString("en")).toBe("12,34"); - expect([12, 34].toLocaleString("ar")).toBe("\u0661\u0662,\u0663\u0664"); + expect([12, 34].toLocaleString("ar-u-nu-arab")).toBe("\u0661\u0662,\u0663\u0664"); expect([0.234].toLocaleString("en", { style: "percent" })).toBe("23%"); - expect([0.234].toLocaleString("ar", { style: "percent" })).toBe("\u0662\u0663\u066a\u061c"); + expect([0.234].toLocaleString("ar-u-nu-arab", { style: "percent" })).toBe( + "\u0662\u0663\u066a\u061c" + ); }); }); diff --git a/Libraries/LibJS/Tests/builtins/BigInt/BigInt.prototype.toLocaleString.js b/Libraries/LibJS/Tests/builtins/BigInt/BigInt.prototype.toLocaleString.js index 0fd16922923..d33b7ba5e3b 100644 --- a/Libraries/LibJS/Tests/builtins/BigInt/BigInt.prototype.toLocaleString.js +++ b/Libraries/LibJS/Tests/builtins/BigInt/BigInt.prototype.toLocaleString.js @@ -17,11 +17,11 @@ test("default", () => { "123,456,789,123,456,789,123,456,789,123,456,789" ); - const ar = new Intl.NumberFormat("ar"); - expect(1n.toLocaleString("ar")).toBe("\u0661"); - expect(12n.toLocaleString("ar")).toBe("\u0661\u0662"); - expect(123n.toLocaleString("ar")).toBe("\u0661\u0662\u0663"); - expect(123456789123456789123456789123456789n.toLocaleString("ar")).toBe( + const ar = new Intl.NumberFormat("ar-u-nu-arab"); + expect(1n.toLocaleString("ar-u-nu-arab")).toBe("\u0661"); + expect(12n.toLocaleString("ar-u-nu-arab")).toBe("\u0661\u0662"); + expect(123n.toLocaleString("ar-u-nu-arab")).toBe("\u0661\u0662\u0663"); + expect(123456789123456789123456789123456789n.toLocaleString("ar-u-nu-arab")).toBe( "\u0661\u0662\u0663\u066c\u0664\u0665\u0666\u066c\u0667\u0668\u0669\u066c\u0661\u0662\u0663\u066c\u0664\u0665\u0666\u066c\u0667\u0668\u0669\u066c\u0661\u0662\u0663\u066c\u0664\u0665\u0666\u066c\u0667\u0668\u0669\u066c\u0661\u0662\u0663\u066c\u0664\u0665\u0666\u066c\u0667\u0668\u0669" ); }); @@ -31,9 +31,11 @@ test("integer digits", () => { expect(12n.toLocaleString("en", { minimumIntegerDigits: 2 })).toBe("12"); expect(123n.toLocaleString("en", { minimumIntegerDigits: 2 })).toBe("123"); - expect(1n.toLocaleString("ar", { minimumIntegerDigits: 2 })).toBe("\u0660\u0661"); - expect(12n.toLocaleString("ar", { minimumIntegerDigits: 2 })).toBe("\u0661\u0662"); - expect(123n.toLocaleString("ar", { minimumIntegerDigits: 2 })).toBe("\u0661\u0662\u0663"); + expect(1n.toLocaleString("ar-u-nu-arab", { minimumIntegerDigits: 2 })).toBe("\u0660\u0661"); + expect(12n.toLocaleString("ar-u-nu-arab", { minimumIntegerDigits: 2 })).toBe("\u0661\u0662"); + expect(123n.toLocaleString("ar-u-nu-arab", { minimumIntegerDigits: 2 })).toBe( + "\u0661\u0662\u0663" + ); }); test("significant digits", () => { @@ -63,27 +65,51 @@ test("significant digits", () => { ).toBe("1,234,560"); expect( - 1n.toLocaleString("ar", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 }) + 1n.toLocaleString("ar-u-nu-arab", { + minimumSignificantDigits: 4, + maximumSignificantDigits: 6, + }) ).toBe("\u0661\u066b\u0660\u0660\u0660"); expect( - 12n.toLocaleString("ar", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 }) + 12n.toLocaleString("ar-u-nu-arab", { + minimumSignificantDigits: 4, + maximumSignificantDigits: 6, + }) ).toBe("\u0661\u0662\u066b\u0660\u0660"); expect( - 123n.toLocaleString("ar", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 }) + 123n.toLocaleString("ar-u-nu-arab", { + minimumSignificantDigits: 4, + maximumSignificantDigits: 6, + }) ).toBe("\u0661\u0662\u0663\u066b\u0660"); expect( - 1234n.toLocaleString("ar", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 }) + 1234n.toLocaleString("ar-u-nu-arab", { + minimumSignificantDigits: 4, + maximumSignificantDigits: 6, + }) ).toBe("\u0661\u066c\u0662\u0663\u0664"); expect( - 12345n.toLocaleString("ar", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 }) + 12345n.toLocaleString("ar-u-nu-arab", { + minimumSignificantDigits: 4, + maximumSignificantDigits: 6, + }) ).toBe("\u0661\u0662\u066c\u0663\u0664\u0665"); expect( - 123456n.toLocaleString("ar", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 }) + 123456n.toLocaleString("ar-u-nu-arab", { + minimumSignificantDigits: 4, + maximumSignificantDigits: 6, + }) ).toBe("\u0661\u0662\u0663\u066c\u0664\u0665\u0666"); expect( - 1234567n.toLocaleString("ar", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 }) + 1234567n.toLocaleString("ar-u-nu-arab", { + minimumSignificantDigits: 4, + maximumSignificantDigits: 6, + }) ).toBe("\u0661\u066c\u0662\u0663\u0664\u066c\u0665\u0667\u0660"); expect( - 1234561n.toLocaleString("ar", { minimumSignificantDigits: 4, maximumSignificantDigits: 6 }) + 1234561n.toLocaleString("ar-u-nu-arab", { + minimumSignificantDigits: 4, + maximumSignificantDigits: 6, + }) ).toBe("\u0661\u066c\u0662\u0663\u0664\u066c\u0665\u0666\u0660"); }); diff --git a/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleDateString.js b/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleDateString.js index 6cdc948013f..c5c796e26d8 100644 --- a/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleDateString.js +++ b/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleDateString.js @@ -40,8 +40,8 @@ describe("correct behavior", () => { expect(d0.toLocaleDateString("en", { timeZone: "UTC" })).toBe("12/7/2021"); expect(d1.toLocaleDateString("en", { timeZone: "UTC" })).toBe("1/23/1989"); - expect(d0.toLocaleDateString("ar", { timeZone: "UTC" })).toBe("٧‏/١٢‏/٢٠٢١"); - expect(d1.toLocaleDateString("ar", { timeZone: "UTC" })).toBe("٢٣‏/١‏/١٩٨٩"); + expect(d0.toLocaleDateString("ar-u-nu-arab", { timeZone: "UTC" })).toBe("٧‏/١٢‏/٢٠٢١"); + expect(d1.toLocaleDateString("ar-u-nu-arab", { timeZone: "UTC" })).toBe("٢٣‏/١‏/١٩٨٩"); }); test("dateStyle may be set", () => { @@ -52,10 +52,10 @@ describe("correct behavior", () => { "Monday, January 23, 1989" ); - expect(d0.toLocaleDateString("ar", { dateStyle: "full", timeZone: "UTC" })).toBe( + expect(d0.toLocaleDateString("ar-u-nu-arab", { dateStyle: "full", timeZone: "UTC" })).toBe( "الثلاثاء، ٧ ديسمبر ٢٠٢١" ); - expect(d1.toLocaleDateString("ar", { dateStyle: "full", timeZone: "UTC" })).toBe( + expect(d1.toLocaleDateString("ar-u-nu-arab", { dateStyle: "full", timeZone: "UTC" })).toBe( "الاثنين، ٢٣ يناير ١٩٨٩" ); }); diff --git a/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleString.js b/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleString.js index 069ae4030a5..b75ff93a645 100644 --- a/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleString.js +++ b/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleString.js @@ -34,18 +34,22 @@ describe("correct behavior", () => { expect(d0.toLocaleString("en", { timeZone: "UTC" })).toBe("12/7/2021, 5:40:50 PM"); expect(d1.toLocaleString("en", { timeZone: "UTC" })).toBe("1/23/1989, 7:08:09 AM"); - expect(d0.toLocaleString("ar", { timeZone: "UTC" })).toBe("٧‏/١٢‏/٢٠٢١، ٥:٤٠:٥٠ م"); - expect(d1.toLocaleString("ar", { timeZone: "UTC" })).toBe("٢٣‏/١‏/١٩٨٩، ٧:٠٨:٠٩ ص"); + expect(d0.toLocaleString("ar-u-nu-arab", { timeZone: "UTC" })).toBe( + "٧‏/١٢‏/٢٠٢١، ٥:٤٠:٥٠ م" + ); + expect(d1.toLocaleString("ar-u-nu-arab", { timeZone: "UTC" })).toBe( + "٢٣‏/١‏/١٩٨٩، ٧:٠٨:٠٩ ص" + ); }); test("dateStyle may be set", () => { expect(d0.toLocaleString("en", { dateStyle: "short", timeZone: "UTC" })).toBe("12/7/21"); expect(d1.toLocaleString("en", { dateStyle: "short", timeZone: "UTC" })).toBe("1/23/89"); - expect(d0.toLocaleString("ar", { dateStyle: "short", timeZone: "UTC" })).toBe( + expect(d0.toLocaleString("ar-u-nu-arab", { dateStyle: "short", timeZone: "UTC" })).toBe( "٧‏/١٢‏/٢٠٢١" ); - expect(d1.toLocaleString("ar", { dateStyle: "short", timeZone: "UTC" })).toBe( + expect(d1.toLocaleString("ar-u-nu-arab", { dateStyle: "short", timeZone: "UTC" })).toBe( "٢٣‏/١‏/١٩٨٩" ); }); @@ -54,7 +58,11 @@ describe("correct behavior", () => { expect(d0.toLocaleString("en", { timeStyle: "short", timeZone: "UTC" })).toBe("5:40 PM"); expect(d1.toLocaleString("en", { timeStyle: "short", timeZone: "UTC" })).toBe("7:08 AM"); - expect(d0.toLocaleString("ar", { timeStyle: "short", timeZone: "UTC" })).toBe("٥:٤٠ م"); - expect(d1.toLocaleString("ar", { timeStyle: "short", timeZone: "UTC" })).toBe("٧:٠٨ ص"); + expect(d0.toLocaleString("ar-u-nu-arab", { timeStyle: "short", timeZone: "UTC" })).toBe( + "٥:٤٠ م" + ); + expect(d1.toLocaleString("ar-u-nu-arab", { timeStyle: "short", timeZone: "UTC" })).toBe( + "٧:٠٨ ص" + ); }); }); diff --git a/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleTimeString.js b/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleTimeString.js index d1889940398..2059428ff0d 100644 --- a/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleTimeString.js +++ b/Libraries/LibJS/Tests/builtins/Date/Date.prototype.toLocaleTimeString.js @@ -40,8 +40,8 @@ describe("correct behavior", () => { expect(d0.toLocaleTimeString("en", { timeZone: "UTC" })).toBe("5:40:50 PM"); expect(d1.toLocaleTimeString("en", { timeZone: "UTC" })).toBe("7:08:09 AM"); - expect(d0.toLocaleTimeString("ar", { timeZone: "UTC" })).toBe("٥:٤٠:٥٠ م"); - expect(d1.toLocaleTimeString("ar", { timeZone: "UTC" })).toBe("٧:٠٨:٠٩ ص"); + expect(d0.toLocaleTimeString("ar-u-nu-arab", { timeZone: "UTC" })).toBe("٥:٤٠:٥٠ م"); + expect(d1.toLocaleTimeString("ar-u-nu-arab", { timeZone: "UTC" })).toBe("٧:٠٨:٠٩ ص"); }); test("timeStyle may be set", () => { @@ -52,10 +52,10 @@ describe("correct behavior", () => { "7:08:09 AM UTC" ); - expect(d0.toLocaleTimeString("ar", { timeStyle: "long", timeZone: "UTC" })).toBe( + expect(d0.toLocaleTimeString("ar-u-nu-arab", { timeStyle: "long", timeZone: "UTC" })).toBe( "٥:٤٠:٥٠ م UTC" ); - expect(d1.toLocaleTimeString("ar", { timeStyle: "long", timeZone: "UTC" })).toBe( + expect(d1.toLocaleTimeString("ar-u-nu-arab", { timeStyle: "long", timeZone: "UTC" })).toBe( "٧:٠٨:٠٩ ص UTC" ); }); diff --git a/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.format.js b/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.format.js index ec3a29ee3bf..2fa055bf1c0 100644 --- a/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.format.js +++ b/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.format.js @@ -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", diff --git a/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.formatToParts.js b/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.formatToParts.js index 30d6fee1b79..9ca0b871c91 100644 --- a/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.formatToParts.js +++ b/Libraries/LibJS/Tests/builtins/Intl/DateTimeFormat/DateTimeFormat.prototype.formatToParts.js @@ -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", diff --git a/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.format.js b/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.format.js index 38a3346121e..6775ac80c92 100644 --- a/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.format.js +++ b/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.format.js @@ -23,7 +23,7 @@ describe("special values", () => { expect(en.format(NaN)).toBe("NaN"); expect(en.format(undefined)).toBe("NaN"); - const ar = new Intl.NumberFormat("ar"); + const ar = new Intl.NumberFormat("ar-u-nu-arab"); expect(ar.format()).toBe("ليس رقم"); expect(ar.format(NaN)).toBe("ليس رقم"); expect(ar.format(undefined)).toBe("ليس رقم"); @@ -34,7 +34,7 @@ describe("special values", () => { expect(en.format(Infinity)).toBe("∞"); expect(en.format(-Infinity)).toBe("-∞"); - const ar = new Intl.NumberFormat("ar"); + const ar = new Intl.NumberFormat("ar-u-nu-arab"); expect(ar.format(Infinity)).toBe("∞"); expect(ar.format(-Infinity)).toBe("\u061c-∞"); }); @@ -48,7 +48,7 @@ describe("style=decimal", () => { expect(en.format(123)).toBe("123"); expect(en.format("987654321987654321")).toBe("987,654,321,987,654,321"); - const ar = new Intl.NumberFormat("ar"); + const ar = new Intl.NumberFormat("ar-u-nu-arab"); expect(ar.format(1)).toBe("\u0661"); expect(ar.format(12)).toBe("\u0661\u0662"); expect(ar.format(123)).toBe("\u0661\u0662\u0663"); @@ -63,7 +63,7 @@ describe("style=decimal", () => { expect(en.format(12)).toBe("12"); expect(en.format(123)).toBe("123"); - const ar = new Intl.NumberFormat("ar", { minimumIntegerDigits: 2 }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { minimumIntegerDigits: 2 }); expect(ar.format(1)).toBe("\u0660\u0661"); expect(ar.format(12)).toBe("\u0661\u0662"); expect(ar.format(123)).toBe("\u0661\u0662\u0663"); @@ -111,7 +111,7 @@ describe("style=decimal", () => { "123,456,789,123,456,789,123,000,000,000,000,000" ); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { minimumSignificantDigits: 4, maximumSignificantDigits: 6, }); @@ -146,7 +146,7 @@ describe("style=decimal", () => { "-12,344,501,000,000,000,000,000,000,000,000,000.000" ); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { minimumFractionDigits: 3, maximumFractionDigits: 5, }); @@ -179,7 +179,7 @@ describe("style=decimal", () => { expect(en.format(0.12)).toBe("1.2E-1"); expect(en.format(0.01)).toBe("1E-2"); - const ar = new Intl.NumberFormat("ar", { notation: "scientific" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { notation: "scientific" }); expect(ar.format(1)).toBe("\u0661\u0623\u0633\u0660"); expect(ar.format(1.2)).toBe("\u0661\u066b\u0662\u0623\u0633\u0660"); expect(ar.format(12)).toBe("\u0661\u066b\u0662\u0623\u0633\u0661"); @@ -204,7 +204,7 @@ describe("style=decimal", () => { expect(en.format(0.12)).toBe("120E-3"); expect(en.format(1.23)).toBe("1.23E0"); - const ar = new Intl.NumberFormat("ar", { notation: "engineering" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { notation: "engineering" }); expect(ar.format(1)).toBe("\u0661\u0623\u0633\u0660"); expect(ar.format(1.2)).toBe("\u0661\u066b\u0662\u0623\u0633\u0660"); expect(ar.format(12)).toBe("\u0661\u0662\u0623\u0633\u0660"); @@ -230,7 +230,7 @@ describe("style=decimal", () => { expect(en.format(12.3)).toBe("12"); expect(en.format(12.34)).toBe("12"); - const ar = new Intl.NumberFormat("ar", { notation: "compact" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { notation: "compact" }); expect(ar.format(1)).toBe("\u0661"); expect(ar.format(1.2)).toBe("\u0661\u066b\u0662"); expect(ar.format(1.23)).toBe("\u0661\u066b\u0662"); @@ -267,7 +267,10 @@ describe("style=decimal", () => { expect(enFullwide.format(12000000)).toBe("12 million"); expect(enFullwide.format(12900000)).toBe("13 million"); - const ar = new Intl.NumberFormat("ar", { notation: "compact", compactDisplay: "long" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + notation: "compact", + compactDisplay: "long", + }); expect(ar.format(1)).toBe("\u0661"); expect(ar.format(1200)).toBe("\u0661\u066b\u0662 ألف"); expect(ar.format(1290)).toBe("\u0661\u066b\u0663 ألف"); @@ -317,7 +320,10 @@ describe("style=decimal", () => { expect(en.format(12000000)).toBe("12M"); expect(en.format(12900000)).toBe("13M"); - const ar = new Intl.NumberFormat("ar", { notation: "compact", compactDisplay: "short" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + notation: "compact", + compactDisplay: "short", + }); expect(ar.format(1)).toBe("\u0661"); expect(ar.format(1200)).toBe("\u0661\u066b\u0662\u00a0ألف"); expect(ar.format(1290)).toBe("\u0661\u066b\u0663\u00a0ألف"); @@ -360,7 +366,7 @@ describe("style=decimal", () => { expect(en.format(1)).toBe("1"); expect(en.format(-1)).toBe("1"); - const ar = new Intl.NumberFormat("ar", { signDisplay: "never" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "never" }); expect(ar.format(1)).toBe("\u0661"); expect(ar.format(-1)).toBe("\u0661"); }); @@ -372,7 +378,7 @@ describe("style=decimal", () => { expect(en.format(-0)).toBe("-0"); expect(en.format(-1)).toBe("-1"); - const ar = new Intl.NumberFormat("ar", { signDisplay: "auto" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "auto" }); expect(ar.format(0)).toBe("\u0660"); expect(ar.format(1)).toBe("\u0661"); expect(ar.format(-0)).toBe("\u061c-\u0660"); @@ -386,7 +392,7 @@ describe("style=decimal", () => { expect(en.format(-0)).toBe("-0"); expect(en.format(-1)).toBe("-1"); - const ar = new Intl.NumberFormat("ar", { signDisplay: "always" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "always" }); expect(ar.format(0)).toBe("\u061c+\u0660"); expect(ar.format(1)).toBe("\u061c+\u0661"); expect(ar.format(-0)).toBe("\u061c-\u0660"); @@ -400,7 +406,7 @@ describe("style=decimal", () => { expect(en.format(-0)).toBe("0"); expect(en.format(-1)).toBe("-1"); - const ar = new Intl.NumberFormat("ar", { signDisplay: "exceptZero" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "exceptZero" }); expect(ar.format(0)).toBe("\u0660"); expect(ar.format(1)).toBe("\u061c+\u0661"); expect(ar.format(-0)).toBe("\u0660"); @@ -414,7 +420,7 @@ describe("style=decimal", () => { expect(en.format(-0)).toBe("0"); expect(en.format(-1)).toBe("-1"); - const ar = new Intl.NumberFormat("ar", { signDisplay: "negative" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "negative" }); expect(ar.format(0)).toBe("\u0660"); expect(ar.format(1)).toBe("\u0661"); expect(ar.format(-0)).toBe("\u0660"); @@ -436,7 +442,7 @@ describe("style=decimal", () => { expect(enIn.format(123456)).toBe("1,23,456"); expect(enIn.format(1234567)).toBe("12,34,567"); - const ar = new Intl.NumberFormat("ar", { useGrouping: "always" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { useGrouping: "always" }); expect(ar.format(123)).toBe("\u0661\u0662\u0663"); expect(ar.format(1234)).toBe("\u0661\u066c\u0662\u0663\u0664"); expect(ar.format(12345)).toBe("\u0661\u0662\u066c\u0663\u0664\u0665"); @@ -466,7 +472,7 @@ describe("style=decimal", () => { expect(enIn.format(123456)).toBe("1,23,456"); expect(enIn.format(1234567)).toBe("12,34,567"); - const ar = new Intl.NumberFormat("ar", { useGrouping: "auto" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { useGrouping: "auto" }); expect(ar.format(123)).toBe("\u0661\u0662\u0663"); expect(ar.format(1234)).toBe("\u0661\u066c\u0662\u0663\u0664"); expect(ar.format(12345)).toBe("\u0661\u0662\u066c\u0663\u0664\u0665"); @@ -496,7 +502,7 @@ describe("style=decimal", () => { expect(enIn.format(123456)).toBe("1,23,456"); expect(enIn.format(1234567)).toBe("12,34,567"); - const ar = new Intl.NumberFormat("ar", { useGrouping: "min2" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { useGrouping: "min2" }); expect(ar.format(123)).toBe("\u0661\u0662\u0663"); expect(ar.format(1234)).toBe("\u0661\u0662\u0663\u0664"); expect(ar.format(12345)).toBe("\u0661\u0662\u066c\u0663\u0664\u0665"); @@ -526,7 +532,7 @@ describe("style=decimal", () => { expect(enIn.format(123456)).toBe("123456"); expect(enIn.format(1234567)).toBe("1234567"); - const ar = new Intl.NumberFormat("ar", { useGrouping: false }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { useGrouping: false }); expect(ar.format(123)).toBe("\u0661\u0662\u0663"); expect(ar.format(1234)).toBe("\u0661\u0662\u0663\u0664"); expect(ar.format(12345)).toBe("\u0661\u0662\u0663\u0664\u0665"); @@ -557,10 +563,16 @@ describe("style=decimal", () => { expect(nf("en", undefined, 2, undefined, 2).format(1.23)).toBe("1.2"); expect(nf("en", undefined, 3, undefined, 1).format(1.23)).toBe("1.2"); - expect(nf("ar", 2, undefined, 2, undefined).format(1)).toBe("\u0661\u066b\u0660\u0660"); - expect(nf("ar", 3, undefined, 1, undefined).format(1)).toBe("\u0661\u066b\u0660"); - expect(nf("ar", undefined, 2, undefined, 2).format(1.23)).toBe("\u0661\u066b\u0662"); - expect(nf("ar", undefined, 3, undefined, 1).format(1.23)).toBe("\u0661\u066b\u0662"); + expect(nf("ar-u-nu-arab", 2, undefined, 2, undefined).format(1)).toBe( + "\u0661\u066b\u0660\u0660" + ); + expect(nf("ar-u-nu-arab", 3, undefined, 1, undefined).format(1)).toBe("\u0661\u066b\u0660"); + expect(nf("ar-u-nu-arab", undefined, 2, undefined, 2).format(1.23)).toBe( + "\u0661\u066b\u0662" + ); + expect(nf("ar-u-nu-arab", undefined, 3, undefined, 1).format(1.23)).toBe( + "\u0661\u066b\u0662" + ); }); test("roundingPriority=morePrecision", () => { @@ -579,10 +591,16 @@ describe("style=decimal", () => { expect(nf("en", undefined, 2, undefined, 2).format(1.23)).toBe("1.23"); expect(nf("en", undefined, 3, undefined, 1).format(1.23)).toBe("1.23"); - expect(nf("ar", 2, undefined, 2, undefined).format(1)).toBe("\u0661\u066b\u0660"); - expect(nf("ar", 3, undefined, 1, undefined).format(1)).toBe("\u0661\u066b\u0660\u0660"); - expect(nf("ar", undefined, 2, undefined, 2).format(1.23)).toBe("\u0661\u066b\u0662\u0663"); - expect(nf("ar", undefined, 3, undefined, 1).format(1.23)).toBe("\u0661\u066b\u0662\u0663"); + expect(nf("ar-u-nu-arab", 2, undefined, 2, undefined).format(1)).toBe("\u0661\u066b\u0660"); + expect(nf("ar-u-nu-arab", 3, undefined, 1, undefined).format(1)).toBe( + "\u0661\u066b\u0660\u0660" + ); + expect(nf("ar-u-nu-arab", undefined, 2, undefined, 2).format(1.23)).toBe( + "\u0661\u066b\u0662\u0663" + ); + expect(nf("ar-u-nu-arab", undefined, 3, undefined, 1).format(1.23)).toBe( + "\u0661\u066b\u0662\u0663" + ); }); test("roundingMode=ceil", () => { @@ -597,7 +615,7 @@ describe("style=decimal", () => { expect(en.format(-1.15)).toBe("-1.1"); expect(en.format(-1.2)).toBe("-1.2"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { maximumSignificantDigits: 2, roundingMode: "ceil", }); @@ -621,7 +639,7 @@ describe("style=decimal", () => { expect(en.format(-1.15)).toBe("-1.2"); expect(en.format(-1.2)).toBe("-1.2"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { maximumSignificantDigits: 2, roundingMode: "expand", }); @@ -645,7 +663,7 @@ describe("style=decimal", () => { expect(en.format(-1.15)).toBe("-1.2"); expect(en.format(-1.2)).toBe("-1.2"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { maximumSignificantDigits: 2, roundingMode: "floor", }); @@ -669,7 +687,7 @@ describe("style=decimal", () => { expect(en.format(-1.15)).toBe("-1.1"); expect(en.format(-1.2)).toBe("-1.2"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { maximumSignificantDigits: 2, roundingMode: "halfCeil", }); @@ -693,7 +711,7 @@ describe("style=decimal", () => { expect(en.format(-1.15)).toBe("-1.2"); expect(en.format(-1.2)).toBe("-1.2"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { maximumSignificantDigits: 2, roundingMode: "halfEven", }); @@ -717,7 +735,7 @@ describe("style=decimal", () => { expect(en.format(-1.15)).toBe("-1.2"); expect(en.format(-1.2)).toBe("-1.2"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { maximumSignificantDigits: 2, roundingMode: "halfExpand", }); @@ -741,7 +759,7 @@ describe("style=decimal", () => { expect(en.format(-1.15)).toBe("-1.2"); expect(en.format(-1.2)).toBe("-1.2"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { maximumSignificantDigits: 2, roundingMode: "halfFloor", }); @@ -765,7 +783,7 @@ describe("style=decimal", () => { expect(en.format(-1.15)).toBe("-1.1"); expect(en.format(-1.2)).toBe("-1.2"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { maximumSignificantDigits: 2, roundingMode: "halfTrunc", }); @@ -789,7 +807,7 @@ describe("style=decimal", () => { expect(en.format(-1.15)).toBe("-1.1"); expect(en.format(-1.2)).toBe("-1.2"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { maximumSignificantDigits: 2, roundingMode: "trunc", }); @@ -924,7 +942,7 @@ describe("style=decimal", () => { expect(en.format(12n)).toBe("12.000"); expect(en.format(1.2)).toBe("1.2000"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { trailingZeroDisplay: "auto", minimumSignificantDigits: 5, }); @@ -946,7 +964,7 @@ describe("style=decimal", () => { expect(en.format(12n)).toBe("12"); expect(en.format(1.2)).toBe("1.2000"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { trailingZeroDisplay: "stripIfInteger", minimumSignificantDigits: 5, }); @@ -965,7 +983,7 @@ describe("style=percent", () => { expect(en.format(1.2)).toBe("120%"); expect(en.format(0.234)).toBe("23%"); - const ar = new Intl.NumberFormat("ar", { style: "percent" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "percent" }); expect(ar.format(1)).toBe("\u0661\u0660\u0660\u066a\u061c"); expect(ar.format(1.2)).toBe("\u0661\u0662\u0660\u066a\u061c"); expect(ar.format(0.234)).toBe("\u0662\u0663\u066a\u061c"); @@ -977,7 +995,10 @@ describe("style=percent", () => { expect(en.format(0.12)).toBe("12%"); expect(en.format(1.23)).toBe("123%"); - const ar = new Intl.NumberFormat("ar", { style: "percent", minimumIntegerDigits: 2 }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + minimumIntegerDigits: 2, + }); expect(ar.format(0.01)).toBe("\u0660\u0661\u066a\u061c"); expect(ar.format(0.12)).toBe("\u0661\u0662\u066a\u061c"); expect(ar.format(1.23)).toBe("\u0661\u0662\u0663\u066a\u061c"); @@ -998,7 +1019,7 @@ describe("style=percent", () => { expect(en.format(1.234567)).toBe("123.457%"); expect(en.format(1.234561)).toBe("123.456%"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "percent", minimumSignificantDigits: 4, maximumSignificantDigits: 6, @@ -1029,7 +1050,7 @@ describe("style=percent", () => { expect(en.format(0.1234567)).toBe("12.3457%"); expect(en.format(0.1234561)).toBe("12.3456%"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "percent", minimumFractionDigits: 2, maximumFractionDigits: 4, @@ -1068,7 +1089,7 @@ describe("style=percent", () => { expect(enFullwide.format(0.123)).toBe("12%"); expect(enFullwide.format(0.1234)).toBe("12%"); - const ar = new Intl.NumberFormat("ar", { style: "percent", notation: "compact" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "percent", notation: "compact" }); expect(ar.format(0.01)).toBe("\u0661\u066a"); expect(ar.format(0.012)).toBe("\u0661\u066b\u0662\u066a"); expect(ar.format(0.0123)).toBe("\u0661\u066b\u0662\u066a"); @@ -1083,7 +1104,10 @@ describe("style=percent", () => { expect(en.format(0.01)).toBe("1%"); expect(en.format(-0.01)).toBe("1%"); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "never" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + signDisplay: "never", + }); expect(ar.format(0.01)).toBe("\u0661\u066a\u061c"); expect(ar.format(-0.01)).toBe("\u0661\u066a\u061c"); }); @@ -1095,7 +1119,7 @@ describe("style=percent", () => { expect(en.format(-0.0)).toBe("-0%"); expect(en.format(-0.01)).toBe("-1%"); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "auto" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "percent", signDisplay: "auto" }); expect(ar.format(0.0)).toBe("\u0660\u066a\u061c"); expect(ar.format(0.01)).toBe("\u0661\u066a\u061c"); expect(ar.format(-0.0)).toBe("\u061c-\u0660\u066a\u061c"); @@ -1109,7 +1133,10 @@ describe("style=percent", () => { expect(en.format(-0.0)).toBe("-0%"); expect(en.format(-0.01)).toBe("-1%"); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "always" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + signDisplay: "always", + }); expect(ar.format(0.0)).toBe("\u061c+\u0660\u066a\u061c"); expect(ar.format(0.01)).toBe("\u061c+\u0661\u066a\u061c"); expect(ar.format(-0.0)).toBe("\u061c-\u0660\u066a\u061c"); @@ -1123,7 +1150,10 @@ describe("style=percent", () => { expect(en.format(-0.0)).toBe("0%"); expect(en.format(-0.01)).toBe("-1%"); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "exceptZero" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + signDisplay: "exceptZero", + }); expect(ar.format(0.0)).toBe("\u0660\u066a\u061c"); expect(ar.format(0.01)).toBe("\u061c+\u0661\u066a\u061c"); expect(ar.format(-0.0)).toBe("\u0660\u066a\u061c"); @@ -1137,7 +1167,10 @@ describe("style=percent", () => { expect(en.format(-0.0)).toBe("0%"); expect(en.format(-0.01)).toBe("-1%"); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "negative" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + signDisplay: "negative", + }); expect(ar.format(0.0)).toBe("\u0660\u066a\u061c"); expect(ar.format(0.01)).toBe("\u0661\u066a\u061c"); expect(ar.format(-0.0)).toBe("\u0660\u066a\u061c"); @@ -1165,7 +1198,7 @@ describe("style=currency", () => { expect(en2.format(1.2)).toBe("KHR\u00a01.20"); expect(en2.format(1.23)).toBe("KHR\u00a01.23"); - const ar1 = new Intl.NumberFormat("ar", { + const ar1 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "code", @@ -1174,7 +1207,7 @@ describe("style=currency", () => { expect(ar1.format(1.2)).toBe("\u200f\u0661\u066b\u0662\u0660\u00a0USD"); expect(ar1.format(1.23)).toBe("\u200f\u0661\u066b\u0662\u0663\u00a0USD"); - const ar2 = new Intl.NumberFormat("ar", { + const ar2 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "code", @@ -1204,7 +1237,7 @@ describe("style=currency", () => { expect(en2.format(1.2)).toBe("KHR\u00a01.20"); expect(en2.format(1.23)).toBe("KHR\u00a01.23"); - const ar1 = new Intl.NumberFormat("ar", { + const ar1 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "symbol", @@ -1213,7 +1246,7 @@ describe("style=currency", () => { expect(ar1.format(1.2)).toBe("\u200f\u0661\u066b\u0662\u0660\u00a0US$"); expect(ar1.format(1.23)).toBe("\u200f\u0661\u066b\u0662\u0663\u00a0US$"); - const ar2 = new Intl.NumberFormat("ar", { + const ar2 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "symbol", @@ -1243,7 +1276,7 @@ describe("style=currency", () => { expect(en2.format(1.2)).toBe("៛1.20"); expect(en2.format(1.23)).toBe("៛1.23"); - const ar1 = new Intl.NumberFormat("ar", { + const ar1 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "narrowSymbol", @@ -1252,7 +1285,7 @@ describe("style=currency", () => { expect(ar1.format(1.2)).toBe("\u200f\u0661\u066b\u0662\u0660\u00a0US$"); expect(ar1.format(1.23)).toBe("\u200f\u0661\u066b\u0662\u0663\u00a0US$"); - const ar2 = new Intl.NumberFormat("ar", { + const ar2 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "narrowSymbol", @@ -1282,7 +1315,7 @@ describe("style=currency", () => { expect(en2.format(1.2)).toBe("1.20 Cambodian riels"); expect(en2.format(1.23)).toBe("1.23 Cambodian riels"); - const ar1 = new Intl.NumberFormat("ar", { + const ar1 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "name", @@ -1291,7 +1324,7 @@ describe("style=currency", () => { expect(ar1.format(1.2)).toBe("\u0661\u066b\u0662\u0660 دولار أمريكي"); expect(ar1.format(1.23)).toBe("\u0661\u066b\u0662\u0663 دولار أمريكي"); - const ar2 = new Intl.NumberFormat("ar", { + const ar2 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "name", @@ -1319,7 +1352,7 @@ describe("style=currency", () => { expect(en.format(12000000)).toBe("$12M"); expect(en.format(12900000)).toBe("$13M"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", notation: "compact", @@ -1389,7 +1422,7 @@ describe("style=currency", () => { expect(en.format(12000000)).toBe("$12M"); expect(en.format(12900000)).toBe("$13M"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", notation: "compact", @@ -1460,7 +1493,7 @@ describe("style=currency", () => { expect(en2.format(1)).toBe("$1.00"); expect(en2.format(-1)).toBe("$1.00"); - const ar1 = new Intl.NumberFormat("ar", { + const ar1 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "never", @@ -1468,7 +1501,7 @@ describe("style=currency", () => { expect(ar1.format(1)).toBe("\u200f\u0661\u066b\u0660\u0660\u00a0US$"); expect(ar1.format(-1)).toBe("\u200f\u0661\u066b\u0660\u0660\u00a0US$"); - const ar2 = new Intl.NumberFormat("ar", { + const ar2 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencySign: "accounting", @@ -1500,7 +1533,7 @@ describe("style=currency", () => { expect(en2.format(-0)).toBe("($0.00)"); expect(en2.format(-1)).toBe("($1.00)"); - const ar1 = new Intl.NumberFormat("ar", { + const ar1 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "auto", @@ -1510,7 +1543,7 @@ describe("style=currency", () => { expect(ar1.format(-0)).toBe("\u061c-\u200f\u0660\u066b\u0660\u0660\u00a0US$"); expect(ar1.format(-1)).toBe("\u061c-\u200f\u0661\u066b\u0660\u0660\u00a0US$"); - const ar2 = new Intl.NumberFormat("ar", { + const ar2 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencySign: "accounting", @@ -1544,7 +1577,7 @@ describe("style=currency", () => { expect(en2.format(-0)).toBe("($0.00)"); expect(en2.format(-1)).toBe("($1.00)"); - const ar1 = new Intl.NumberFormat("ar", { + const ar1 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "always", @@ -1554,7 +1587,7 @@ describe("style=currency", () => { expect(ar1.format(-0)).toBe("\u061c-\u200f\u0660\u066b\u0660\u0660\u00a0US$"); expect(ar1.format(-1)).toBe("\u061c-\u200f\u0661\u066b\u0660\u0660\u00a0US$"); - const ar2 = new Intl.NumberFormat("ar", { + const ar2 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencySign: "accounting", @@ -1588,7 +1621,7 @@ describe("style=currency", () => { expect(en2.format(-0)).toBe("$0.00"); expect(en2.format(-1)).toBe("($1.00)"); - const ar1 = new Intl.NumberFormat("ar", { + const ar1 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "exceptZero", @@ -1598,7 +1631,7 @@ describe("style=currency", () => { expect(ar1.format(-0)).toBe("\u200f\u0660\u066b\u0660\u0660\u00a0US$"); expect(ar1.format(-1)).toBe("\u061c-\u200f\u0661\u066b\u0660\u0660\u00a0US$"); - const ar2 = new Intl.NumberFormat("ar", { + const ar2 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencySign: "accounting", @@ -1632,7 +1665,7 @@ describe("style=currency", () => { expect(en2.format(-0)).toBe("$0.00"); expect(en2.format(-1)).toBe("($1.00)"); - const ar1 = new Intl.NumberFormat("ar", { + const ar1 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "negative", @@ -1642,7 +1675,7 @@ describe("style=currency", () => { expect(ar1.format(-0)).toBe("\u200f\u0660\u066b\u0660\u0660\u00a0US$"); expect(ar1.format(-1)).toBe("\u061c-\u200f\u0661\u066b\u0660\u0660\u00a0US$"); - const ar2 = new Intl.NumberFormat("ar", { + const ar2 = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencySign: "accounting", @@ -1684,7 +1717,7 @@ describe("style=unit", () => { expect(en3.format(1.2)).toBe("1.2 nanoseconds"); expect(en3.format(123)).toBe("123 nanoseconds"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "unit", unit: "foot", unitDisplay: "long", @@ -1731,7 +1764,7 @@ describe("style=unit", () => { expect(en3.format(1.2)).toBe("1.2 ns"); expect(en3.format(123)).toBe("123 ns"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "unit", unit: "foot", unitDisplay: "short", @@ -1778,7 +1811,7 @@ describe("style=unit", () => { expect(en3.format(1.2)).toBe("1.2ns"); expect(en3.format(123)).toBe("123ns"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "unit", unit: "foot", unitDisplay: "narrow", @@ -1808,7 +1841,7 @@ describe("bigint", () => { "123,456,789,123,456,789,123,456,789,123,456,789" ); - const ar = new Intl.NumberFormat("ar"); + const ar = new Intl.NumberFormat("ar-u-nu-arab"); expect(ar.format(1n)).toBe("\u0661"); expect(ar.format(12n)).toBe("\u0661\u0662"); expect(ar.format(123n)).toBe("\u0661\u0662\u0663"); @@ -1823,7 +1856,7 @@ describe("bigint", () => { expect(en.format(12n)).toBe("12"); expect(en.format(123n)).toBe("123"); - const ar = new Intl.NumberFormat("ar", { minimumIntegerDigits: 2 }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { minimumIntegerDigits: 2 }); expect(ar.format(1n)).toBe("\u0660\u0661"); expect(ar.format(12n)).toBe("\u0661\u0662"); expect(ar.format(123n)).toBe("\u0661\u0662\u0663"); @@ -1843,7 +1876,7 @@ describe("bigint", () => { expect(en.format(1234567n)).toBe("1,234,570"); expect(en.format(1234561n)).toBe("1,234,560"); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { minimumSignificantDigits: 4, maximumSignificantDigits: 6, }); diff --git a/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.formatToParts.js b/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.formatToParts.js index c102e1c238b..0f6b6792e16 100644 --- a/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.formatToParts.js +++ b/Libraries/LibJS/Tests/builtins/Intl/NumberFormat/NumberFormat.prototype.formatToParts.js @@ -19,7 +19,7 @@ describe("special values", () => { expect(en.formatToParts(NaN)).toEqual([{ type: "nan", value: "NaN" }]); expect(en.formatToParts(undefined)).toEqual([{ type: "nan", value: "NaN" }]); - const ar = new Intl.NumberFormat("ar"); + const ar = new Intl.NumberFormat("ar-u-nu-arab"); expect(ar.formatToParts()).toEqual([{ type: "nan", value: "ليس رقم" }]); expect(ar.formatToParts(NaN)).toEqual([{ type: "nan", value: "ليس رقم" }]); expect(ar.formatToParts(undefined)).toEqual([{ type: "nan", value: "ليس رقم" }]); @@ -33,7 +33,7 @@ describe("special values", () => { { type: "infinity", value: "∞" }, ]); - const ar = new Intl.NumberFormat("ar"); + const ar = new Intl.NumberFormat("ar-u-nu-arab"); expect(ar.formatToParts(Infinity)).toEqual([{ type: "infinity", value: "∞" }]); expect(ar.formatToParts(-Infinity)).toEqual([ { type: "literal", value: "\u061c" }, @@ -58,7 +58,7 @@ describe("style=decimal", () => { { type: "fraction", value: "3" }, ]); - const ar = new Intl.NumberFormat("ar"); + const ar = new Intl.NumberFormat("ar-u-nu-arab"); expect(ar.formatToParts(123)).toEqual([{ type: "integer", value: "\u0661\u0662\u0663" }]); expect(ar.formatToParts(1.23)).toEqual([ { type: "integer", value: "\u0661" }, @@ -77,7 +77,7 @@ describe("style=decimal", () => { expect(en.formatToParts(1)).toEqual([{ type: "integer", value: "1" }]); expect(en.formatToParts(-1)).toEqual([{ type: "integer", value: "1" }]); - const ar = new Intl.NumberFormat("ar", { signDisplay: "never" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "never" }); expect(ar.formatToParts(1)).toEqual([{ type: "integer", value: "\u0661" }]); expect(ar.formatToParts(-1)).toEqual([{ type: "integer", value: "\u0661" }]); }); @@ -95,7 +95,7 @@ describe("style=decimal", () => { { type: "integer", value: "1" }, ]); - const ar = new Intl.NumberFormat("ar", { signDisplay: "auto" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "auto" }); expect(ar.formatToParts(0)).toEqual([{ type: "integer", value: "\u0660" }]); expect(ar.formatToParts(1)).toEqual([{ type: "integer", value: "\u0661" }]); expect(ar.formatToParts(-0)).toEqual([ @@ -129,7 +129,7 @@ describe("style=decimal", () => { { type: "integer", value: "1" }, ]); - const ar = new Intl.NumberFormat("ar", { signDisplay: "always" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "always" }); expect(ar.formatToParts(0)).toEqual([ { type: "literal", value: "\u061c" }, { type: "plusSign", value: "+" }, @@ -165,7 +165,7 @@ describe("style=decimal", () => { { type: "integer", value: "1" }, ]); - const ar = new Intl.NumberFormat("ar", { signDisplay: "exceptZero" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "exceptZero" }); expect(ar.formatToParts(0)).toEqual([{ type: "integer", value: "\u0660" }]); expect(ar.formatToParts(1)).toEqual([ { type: "literal", value: "\u061c" }, @@ -190,7 +190,7 @@ describe("style=decimal", () => { { type: "integer", value: "1" }, ]); - const ar = new Intl.NumberFormat("ar", { signDisplay: "negative" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { signDisplay: "negative" }); expect(ar.formatToParts(0)).toEqual([{ type: "integer", value: "\u0660" }]); expect(ar.formatToParts(1)).toEqual([{ type: "integer", value: "\u0661" }]); expect(ar.formatToParts(-0)).toEqual([{ type: "integer", value: "\u0660" }]); @@ -258,7 +258,7 @@ describe("style=decimal", () => { { type: "integer", value: "567" }, ]); - const ar = new Intl.NumberFormat("ar", { useGrouping: "auto" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { useGrouping: "auto" }); expect(ar.formatToParts(123456)).toEqual([ { type: "integer", value: "\u0661\u0662\u0663" }, { type: "group", value: "\u066c" }, @@ -300,7 +300,7 @@ describe("style=decimal", () => { expect(enIn.formatToParts(123456)).toEqual([{ type: "integer", value: "123456" }]); expect(enIn.formatToParts(1234567)).toEqual([{ type: "integer", value: "1234567" }]); - const ar = new Intl.NumberFormat("ar", { useGrouping: false }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { useGrouping: false }); expect(ar.formatToParts(123456)).toEqual([ { type: "integer", value: "\u0661\u0662\u0663\u0664\u0665\u0666" }, ]); @@ -327,7 +327,7 @@ describe("style=decimal", () => { { type: "exponentInteger", value: "1" }, ]); - const ar = new Intl.NumberFormat("ar", { notation: "scientific" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { notation: "scientific" }); expect(ar.formatToParts(12.3)).toEqual([ { type: "integer", value: "\u0661" }, { type: "decimal", value: "\u066b" }, @@ -362,7 +362,7 @@ describe("style=decimal", () => { { type: "exponentInteger", value: "3" }, ]); - const ar = new Intl.NumberFormat("ar", { notation: "engineering" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { notation: "engineering" }); expect(ar.formatToParts(1234)).toEqual([ { type: "integer", value: "\u0661" }, { type: "decimal", value: "\u066b" }, @@ -394,7 +394,10 @@ describe("style=decimal", () => { { type: "compact", value: "million" }, ]); - const ar = new Intl.NumberFormat("ar", { notation: "compact", compactDisplay: "long" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + notation: "compact", + compactDisplay: "long", + }); expect(ar.formatToParts(1200)).toEqual([ { type: "integer", value: "\u0661" }, { type: "decimal", value: "\u066b" }, @@ -422,7 +425,10 @@ describe("style=decimal", () => { { type: "compact", value: "M" }, ]); - const ar = new Intl.NumberFormat("ar", { notation: "compact", compactDisplay: "short" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + notation: "compact", + compactDisplay: "short", + }); expect(ar.formatToParts(1200)).toEqual([ { type: "integer", value: "\u0661" }, { type: "decimal", value: "\u066b" }, @@ -454,7 +460,10 @@ describe("style=percent", () => { { type: "percentSign", value: "%" }, ]); - const ar = new Intl.NumberFormat("ar", { style: "percent", minimumFractionDigits: 2 }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + minimumFractionDigits: 2, + }); expect(ar.formatToParts(1)).toEqual([ { type: "integer", value: "\u0661\u0660\u0660" }, { type: "decimal", value: "\u066b" }, @@ -482,7 +491,10 @@ describe("style=percent", () => { { type: "percentSign", value: "%" }, ]); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "never" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + signDisplay: "never", + }); expect(ar.formatToParts(0.01)).toEqual([ { type: "integer", value: "\u0661" }, { type: "percentSign", value: "\u066a" }, @@ -516,7 +528,7 @@ describe("style=percent", () => { { type: "percentSign", value: "%" }, ]); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "auto" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "percent", signDisplay: "auto" }); expect(ar.formatToParts(0.0)).toEqual([ { type: "integer", value: "\u0660" }, { type: "percentSign", value: "\u066a" }, @@ -566,7 +578,10 @@ describe("style=percent", () => { { type: "percentSign", value: "%" }, ]); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "always" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + signDisplay: "always", + }); expect(ar.formatToParts(0.0)).toEqual([ { type: "literal", value: "\u061c" }, { type: "plusSign", value: "+" }, @@ -618,7 +633,10 @@ describe("style=percent", () => { { type: "percentSign", value: "%" }, ]); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "exceptZero" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + signDisplay: "exceptZero", + }); expect(ar.formatToParts(0.0)).toEqual([ { type: "integer", value: "\u0660" }, { type: "percentSign", value: "\u066a" }, @@ -665,7 +683,10 @@ describe("style=percent", () => { { type: "percentSign", value: "%" }, ]); - const ar = new Intl.NumberFormat("ar", { style: "percent", signDisplay: "negative" }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { + style: "percent", + signDisplay: "negative", + }); expect(ar.formatToParts(0.0)).toEqual([ { type: "integer", value: "\u0660" }, { type: "percentSign", value: "\u066a" }, @@ -713,7 +734,7 @@ describe("style=currency", () => { { type: "fraction", value: "23" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "code", @@ -755,7 +776,7 @@ describe("style=currency", () => { { type: "fraction", value: "23" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "symbol", @@ -797,7 +818,7 @@ describe("style=currency", () => { { type: "fraction", value: "23" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "narrowSymbol", @@ -841,7 +862,7 @@ describe("style=currency", () => { { type: "currency", value: "US dollars" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "name", @@ -881,7 +902,7 @@ describe("style=currency", () => { { type: "fraction", value: "00" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "never", @@ -956,7 +977,7 @@ describe("style=currency", () => { { type: "fraction", value: "00" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "auto", @@ -1069,7 +1090,7 @@ describe("style=currency", () => { { type: "fraction", value: "00" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "always", @@ -1186,7 +1207,7 @@ describe("style=currency", () => { { type: "fraction", value: "00" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "exceptZero", @@ -1295,7 +1316,7 @@ describe("style=currency", () => { { type: "fraction", value: "00" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "currency", currency: "USD", signDisplay: "negative", @@ -1408,7 +1429,7 @@ describe("style=unit", () => { { type: "unit", value: "kilometers per hour" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "unit", unit: "foot", unitDisplay: "long", @@ -1482,7 +1503,7 @@ describe("style=unit", () => { { type: "unit", value: "km/h" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "unit", unit: "foot", unitDisplay: "short", @@ -1548,7 +1569,7 @@ describe("style=unit", () => { { type: "unit", value: "km/h" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { style: "unit", unit: "foot", unitDisplay: "narrow", @@ -1589,7 +1610,7 @@ describe("bigint", () => { { type: "integer", value: "456" }, ]); - const ar = new Intl.NumberFormat("ar"); + const ar = new Intl.NumberFormat("ar-u-nu-arab"); expect(ar.formatToParts(123456n)).toEqual([ { type: "integer", value: "\u0661\u0662\u0663" }, { type: "group", value: "\u066c" }, @@ -1601,7 +1622,7 @@ describe("bigint", () => { const en = new Intl.NumberFormat("en", { useGrouping: false }); expect(en.formatToParts(123456n)).toEqual([{ type: "integer", value: "123456" }]); - const ar = new Intl.NumberFormat("ar", { useGrouping: false }); + const ar = new Intl.NumberFormat("ar-u-nu-arab", { useGrouping: false }); expect(ar.formatToParts(123456n)).toEqual([ { type: "integer", value: "\u0661\u0662\u0663\u0664\u0665\u0666" }, ]); @@ -1627,7 +1648,7 @@ describe("bigint", () => { { type: "integer", value: "560" }, ]); - const ar = new Intl.NumberFormat("ar", { + const ar = new Intl.NumberFormat("ar-u-nu-arab", { minimumSignificantDigits: 4, maximumSignificantDigits: 6, }); diff --git a/Libraries/LibJS/Tests/builtins/Intl/RelativeTimeFormat/RelativeTimeFormat.prototype.format.js b/Libraries/LibJS/Tests/builtins/Intl/RelativeTimeFormat/RelativeTimeFormat.prototype.format.js index 44c58074e6d..def30e3c5b2 100644 --- a/Libraries/LibJS/Tests/builtins/Intl/RelativeTimeFormat/RelativeTimeFormat.prototype.format.js +++ b/Libraries/LibJS/Tests/builtins/Intl/RelativeTimeFormat/RelativeTimeFormat.prototype.format.js @@ -52,7 +52,7 @@ describe("errors", () => { let formatters = {}; -["en", "ar", "pl"].forEach(locale => { +["en", "ar-u-nu-arab", "pl"].forEach(locale => { formatters[locale] = {}; ["long", "short", "narrow"].forEach(style => { @@ -72,11 +72,11 @@ function runTest(unit, style, numeric, en, ar, pl) { [-2, -1, -0, 0, 1, 2].forEach((value, i) => { expect(formatters["en"][style][numeric].format(value, unit)).toBe(en[i]); - expect(formatters["ar"][style][numeric].format(value, unit)).toBe(ar[i]); + expect(formatters["ar-u-nu-arab"][style][numeric].format(value, unit)).toBe(ar[i]); expect(formatters["pl"][style][numeric].format(value, unit)).toBe(pl[i]); expect(formatters["en"][style][numeric].format(value, pluralUnit)).toBe(en[i]); - expect(formatters["ar"][style][numeric].format(value, pluralUnit)).toBe(ar[i]); + expect(formatters["ar-u-nu-arab"][style][numeric].format(value, pluralUnit)).toBe(ar[i]); expect(formatters["pl"][style][numeric].format(value, pluralUnit)).toBe(pl[i]); }); } diff --git a/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toLocaleString.js b/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toLocaleString.js index 72ffb245735..4338b29d68c 100644 --- a/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toLocaleString.js +++ b/Libraries/LibJS/Tests/builtins/Number/Number.prototype.toLocaleString.js @@ -19,25 +19,27 @@ describe("special values", () => { test("NaN", () => { expect(NaN.toLocaleString()).toBe("NaN"); expect(NaN.toLocaleString("en")).toBe("NaN"); - expect(NaN.toLocaleString("ar")).toBe("ليس رقم"); + expect(NaN.toLocaleString("ar-u-nu-arab")).toBe("ليس رقم"); }); test("Infinity", () => { expect(Infinity.toLocaleString()).toBe("∞"); expect(Infinity.toLocaleString("en")).toBe("∞"); - expect(Infinity.toLocaleString("ar")).toBe("∞"); + expect(Infinity.toLocaleString("ar-u-nu-arab")).toBe("∞"); }); }); describe("styles", () => { test("decimal", () => { expect((12).toLocaleString("en")).toBe("12"); - expect((12).toLocaleString("ar")).toBe("\u0661\u0662"); + expect((12).toLocaleString("ar-u-nu-arab")).toBe("\u0661\u0662"); }); test("percent", () => { expect((0.234).toLocaleString("en", { style: "percent" })).toBe("23%"); - expect((0.234).toLocaleString("ar", { style: "percent" })).toBe("\u0662\u0663\u066a\u061c"); + expect((0.234).toLocaleString("ar-u-nu-arab", { style: "percent" })).toBe( + "\u0662\u0663\u066a\u061c" + ); }); test("currency", () => { @@ -50,7 +52,7 @@ describe("styles", () => { ).toBe("1.23 US dollars"); expect( - (1.23).toLocaleString("ar", { + (1.23).toLocaleString("ar-u-nu-arab", { style: "currency", currency: "USD", currencyDisplay: "name", @@ -68,7 +70,7 @@ describe("styles", () => { ).toBe("1.23 kilometers per hour"); expect( - (1.23).toLocaleString("ar", { + (1.23).toLocaleString("ar-u-nu-arab", { style: "unit", unit: "kilometer-per-hour", unitDisplay: "long",