فهرست منبع

LibJS: Change Intl.Locale info APIs from property getters to methods

This is a normative change in the Intl Locale Info spec. See:
https://github.com/tc39/proposal-intl-locale-info/commit/e550152
Timothy Flynn 1 سال پیش
والد
کامیت
1d76738dde

+ 7 - 7
Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h

@@ -93,7 +93,6 @@ namespace JS {
     P(byteOffset)                            \
     P(calendar)                              \
     P(calendarName)                          \
-    P(calendars)                             \
     P(call)                                  \
     P(callee)                                \
     P(caller)                                \
@@ -108,7 +107,6 @@ namespace JS {
     P(clz32)                                 \
     P(codePointAt)                           \
     P(collation)                             \
-    P(collations)                            \
     P(compactDisplay)                        \
     P(compareExchange)                       \
     P(compile)                               \
@@ -222,12 +220,15 @@ namespace JS {
     P(get)                                   \
     P(getBigInt64)                           \
     P(getBigUint64)                          \
+    P(getCalendars)                          \
     P(getCanonicalLocales)                   \
+    P(getCollations)                         \
     P(getDate)                               \
     P(getDay)                                \
     P(getFloat32)                            \
     P(getFloat64)                            \
     P(getFullYear)                           \
+    P(getHourCycles)                         \
     P(getHours)                              \
     P(getInstantFor)                         \
     P(getInt8)                               \
@@ -238,6 +239,7 @@ namespace JS {
     P(getMinutes)                            \
     P(getMonth)                              \
     P(getNextTransition)                     \
+    P(getNumberingSystems)                   \
     P(getOffsetNanosecondsFor)               \
     P(getOffsetStringFor)                    \
     P(getOwnPropertyDescriptor)              \
@@ -249,8 +251,10 @@ namespace JS {
     P(getPreviousTransition)                 \
     P(getPrototypeOf)                        \
     P(getSeconds)                            \
+    P(getTextInfo)                           \
     P(getTime)                               \
     P(getTimezoneOffset)                     \
+    P(getTimeZones)                          \
     P(getUint8)                              \
     P(getUint16)                             \
     P(getUint32)                             \
@@ -262,6 +266,7 @@ namespace JS {
     P(getUTCMinutes)                         \
     P(getUTCMonth)                           \
     P(getUTCSeconds)                         \
+    P(getWeekInfo)                           \
     P(getYear)                               \
     P(global)                                \
     P(globalThis)                            \
@@ -278,7 +283,6 @@ namespace JS {
     P(hour)                                  \
     P(hour12)                                \
     P(hourCycle)                             \
-    P(hourCycles)                            \
     P(hours)                                 \
     P(hoursDisplay)                          \
     P(hoursInDay)                            \
@@ -385,7 +389,6 @@ namespace JS {
     P(notation)                              \
     P(now)                                   \
     P(numberingSystem)                       \
-    P(numberingSystems)                      \
     P(numeric)                               \
     P(of)                                    \
     P(offset)                                \
@@ -507,7 +510,6 @@ namespace JS {
     P(tan)                                   \
     P(tanh)                                  \
     P(test)                                  \
-    P(textInfo)                              \
     P(then)                                  \
     P(time)                                  \
     P(timeEnd)                               \
@@ -515,7 +517,6 @@ namespace JS {
     P(timeStyle)                             \
     P(timeZone)                              \
     P(timeZoneName)                          \
-    P(timeZones)                             \
     P(toArray)                               \
     P(toDateString)                          \
     P(toExponential)                         \
@@ -575,7 +576,6 @@ namespace JS {
     P(valueOf)                               \
     P(values)                                \
     P(warn)                                  \
-    P(weekInfo)                              \
     P(weekOfYear)                            \
     P(weekday)                               \
     P(weekend)                               \

+ 22 - 22
Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.cpp

@@ -29,28 +29,28 @@ void LocalePrototype::initialize(Realm& realm)
     define_native_function(realm, vm.names.maximize, maximize, 0, attr);
     define_native_function(realm, vm.names.minimize, minimize, 0, attr);
     define_native_function(realm, vm.names.toString, to_string, 0, attr);
+    define_native_function(realm, vm.names.getCalendars, get_calendars, 0, attr);
+    define_native_function(realm, vm.names.getCollations, get_collations, 0, attr);
+    define_native_function(realm, vm.names.getHourCycles, get_hour_cycles, 0, attr);
+    define_native_function(realm, vm.names.getNumberingSystems, get_numbering_systems, 0, attr);
+    define_native_function(realm, vm.names.getTimeZones, get_time_zones, 0, attr);
+    define_native_function(realm, vm.names.getTextInfo, get_text_info, 0, attr);
+    define_native_function(realm, vm.names.getWeekInfo, get_week_info, 0, attr);
 
     // 14.3.2 Intl.Locale.prototype[ @@toStringTag ], https://tc39.es/ecma402/#sec-Intl.Locale.prototype-@@tostringtag
     define_direct_property(vm.well_known_symbol_to_string_tag(), PrimitiveString::create(vm, "Intl.Locale"_string), Attribute::Configurable);
 
     define_native_accessor(realm, vm.names.baseName, base_name, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.calendar, calendar, {}, Attribute::Configurable);
-    define_native_accessor(realm, vm.names.calendars, calendars, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.caseFirst, case_first, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.collation, collation, {}, Attribute::Configurable);
-    define_native_accessor(realm, vm.names.collations, collations, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.firstDayOfWeek, first_day_of_week, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.hourCycle, hour_cycle, {}, Attribute::Configurable);
-    define_native_accessor(realm, vm.names.hourCycles, hour_cycles, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.numberingSystem, numbering_system, {}, Attribute::Configurable);
-    define_native_accessor(realm, vm.names.numberingSystems, numbering_systems, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.numeric, numeric, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.language, language, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.script, script, {}, Attribute::Configurable);
     define_native_accessor(realm, vm.names.region, region, {}, Attribute::Configurable);
-    define_native_accessor(realm, vm.names.timeZones, time_zones, {}, Attribute::Configurable);
-    define_native_accessor(realm, vm.names.textInfo, text_info, {}, Attribute::Configurable);
-    define_native_accessor(realm, vm.names.weekInfo, week_info, {}, Attribute::Configurable);
 }
 
 // 14.3.3 Intl.Locale.prototype.maximize ( ), https://tc39.es/ecma402/#sec-Intl.Locale.prototype.maximize
@@ -229,21 +229,21 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::region)
     __JS_ENUMERATE(hour_cycles)             \
     __JS_ENUMERATE(numbering_systems)
 
-// 1.4.17 get Intl.Locale.prototype.calendars, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.calendars
-// 1.4.18 get Intl.Locale.prototype.collations, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.collations
-// 1.4.19 get Intl.Locale.prototype.hourCycles, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.hourCycles
-// 1.4.20 get Intl.Locale.prototype.numberingSystems, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.numberingSystems
-#define __JS_ENUMERATE(keyword)                          \
-    JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::keyword)  \
-    {                                                    \
-        auto locale_object = TRY(typed_this_object(vm)); \
-        return keyword##_of_locale(vm, locale_object);   \
+// 1.4.17 Intl.Locale.prototype.getCalendars, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getCalendars
+// 1.4.18 Intl.Locale.prototype.getCollations, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getCollations
+// 1.4.19 Intl.Locale.prototype.getHourCycles, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getHourCycles
+// 1.4.20 Intl.Locale.prototype.getNumberingSystems, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getNumberingSystems
+#define __JS_ENUMERATE(keyword)                               \
+    JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::get_##keyword) \
+    {                                                         \
+        auto locale_object = TRY(typed_this_object(vm));      \
+        return keyword##_of_locale(vm, locale_object);        \
     }
 JS_ENUMERATE_LOCALE_INFO_PROPERTIES
 #undef __JS_ENUMERATE
 
-// 1.4.21 get Intl.Locale.prototype.timeZones, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.timeZones
-JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::time_zones)
+// 1.4.21 Intl.Locale.prototype.getTimeZones, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getTimeZones
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::get_time_zones)
 {
     // 1. Let loc be the this value.
     // 2. Perform ? RequireInternalSlot(loc, [[InitializedLocale]]).
@@ -260,8 +260,8 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::time_zones)
     return time_zones_of_locale(vm, locale->language_id.region.value());
 }
 
-// 1.4.22 get Intl.Locale.prototype.textInfo, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.textInfo
-JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::text_info)
+// 1.4.22 Intl.Locale.prototype.getTextInfo, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getTextInfo
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::get_text_info)
 {
     auto& realm = *vm.current_realm();
 
@@ -282,8 +282,8 @@ JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::text_info)
     return info;
 }
 
-// 1.4.23 get Intl.Locale.prototype.weekInfo, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.weekInfo
-JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::week_info)
+// 1.4.23 Intl.Locale.prototype.getWeekInfo, https://tc39.es/proposal-intl-locale-info/#sec-Intl.Locale.prototype.getWeekInfo
+JS_DEFINE_NATIVE_FUNCTION(LocalePrototype::get_week_info)
 {
     auto& realm = *vm.current_realm();
 

+ 7 - 7
Userland/Libraries/LibJS/Runtime/Intl/LocalePrototype.h

@@ -27,22 +27,22 @@ private:
 
     JS_DECLARE_NATIVE_FUNCTION(base_name);
     JS_DECLARE_NATIVE_FUNCTION(calendar);
-    JS_DECLARE_NATIVE_FUNCTION(calendars);
     JS_DECLARE_NATIVE_FUNCTION(case_first);
     JS_DECLARE_NATIVE_FUNCTION(collation);
-    JS_DECLARE_NATIVE_FUNCTION(collations);
     JS_DECLARE_NATIVE_FUNCTION(first_day_of_week);
     JS_DECLARE_NATIVE_FUNCTION(hour_cycle);
-    JS_DECLARE_NATIVE_FUNCTION(hour_cycles);
     JS_DECLARE_NATIVE_FUNCTION(numbering_system);
-    JS_DECLARE_NATIVE_FUNCTION(numbering_systems);
     JS_DECLARE_NATIVE_FUNCTION(numeric);
     JS_DECLARE_NATIVE_FUNCTION(language);
     JS_DECLARE_NATIVE_FUNCTION(script);
     JS_DECLARE_NATIVE_FUNCTION(region);
-    JS_DECLARE_NATIVE_FUNCTION(time_zones);
-    JS_DECLARE_NATIVE_FUNCTION(text_info);
-    JS_DECLARE_NATIVE_FUNCTION(week_info);
+    JS_DECLARE_NATIVE_FUNCTION(get_calendars);
+    JS_DECLARE_NATIVE_FUNCTION(get_collations);
+    JS_DECLARE_NATIVE_FUNCTION(get_hour_cycles);
+    JS_DECLARE_NATIVE_FUNCTION(get_numbering_systems);
+    JS_DECLARE_NATIVE_FUNCTION(get_time_zones);
+    JS_DECLARE_NATIVE_FUNCTION(get_text_info);
+    JS_DECLARE_NATIVE_FUNCTION(get_week_info);
 };
 
 }

+ 0 - 29
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.calendars.js

@@ -1,29 +0,0 @@
-describe("errors", () => {
-    test("called on non-Locale object", () => {
-        expect(() => {
-            Intl.Locale.prototype.calendars;
-        }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
-    });
-});
-
-describe("normal behavior", () => {
-    test("basic functionality", () => {
-        expect(Array.isArray(new Intl.Locale("en").calendars)).toBeTrue();
-        expect(new Intl.Locale("en").calendars).toEqual(["gregory"]);
-
-        expect(Array.isArray(new Intl.Locale("ar").calendars)).toBeTrue();
-        expect(new Intl.Locale("ar").calendars).toEqual(["gregory"]);
-    });
-
-    test("extension keyword overrides default data", () => {
-        expect(new Intl.Locale("en-u-ca-islamicc").calendars).toEqual(["islamic-civil"]);
-        expect(new Intl.Locale("en", { calendar: "dangi" }).calendars).toEqual(["dangi"]);
-
-        expect(new Intl.Locale("ar-u-ca-ethiopic-amete-alem").calendars).toEqual(["ethioaa"]);
-        expect(new Intl.Locale("ar", { calendar: "hebrew" }).calendars).toEqual(["hebrew"]);
-
-        // Invalid calendars also take precedence.
-        expect(new Intl.Locale("en-u-ca-ladybird").calendars).toEqual(["ladybird"]);
-        expect(new Intl.Locale("en", { calendar: "ladybird" }).calendars).toEqual(["ladybird"]);
-    });
-});

+ 0 - 29
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.collations.js

@@ -1,29 +0,0 @@
-describe("errors", () => {
-    test("called on non-Locale object", () => {
-        expect(() => {
-            Intl.Locale.prototype.collations;
-        }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
-    });
-});
-
-describe("normal behavior", () => {
-    test("basic functionality", () => {
-        expect(Array.isArray(new Intl.Locale("en").collations)).toBeTrue();
-        expect(new Intl.Locale("en").collations).toEqual(["default"]);
-
-        expect(Array.isArray(new Intl.Locale("ar").collations)).toBeTrue();
-        expect(new Intl.Locale("ar").collations).toEqual(["default"]);
-    });
-
-    test("extension keyword overrides default data", () => {
-        expect(new Intl.Locale("en-u-co-compat").collations).toEqual(["compat"]);
-        expect(new Intl.Locale("en", { collation: "compat" }).collations).toEqual(["compat"]);
-
-        expect(new Intl.Locale("ar-u-co-reformed").collations).toEqual(["reformed"]);
-        expect(new Intl.Locale("ar", { collation: "reformed" }).collations).toEqual(["reformed"]);
-
-        // Invalid collations also take precedence.
-        expect(new Intl.Locale("en-u-co-ladybird").collations).toEqual(["ladybird"]);
-        expect(new Intl.Locale("en", { collation: "ladybird" }).collations).toEqual(["ladybird"]);
-    });
-});

+ 31 - 0
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.getCalendars.js

@@ -0,0 +1,31 @@
+describe("errors", () => {
+    test("called on non-Locale object", () => {
+        expect(() => {
+            Intl.Locale.prototype.getCalendars();
+        }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
+    });
+});
+
+describe("normal behavior", () => {
+    test("basic functionality", () => {
+        expect(Array.isArray(new Intl.Locale("en").getCalendars())).toBeTrue();
+        expect(new Intl.Locale("en").getCalendars()).toEqual(["gregory"]);
+
+        expect(Array.isArray(new Intl.Locale("ar").getCalendars())).toBeTrue();
+        expect(new Intl.Locale("ar").getCalendars()).toEqual(["gregory"]);
+    });
+
+    test("extension keyword overrides default data", () => {
+        expect(new Intl.Locale("en-u-ca-islamicc").getCalendars()).toEqual(["islamic-civil"]);
+        expect(new Intl.Locale("en", { calendar: "dangi" }).getCalendars()).toEqual(["dangi"]);
+
+        expect(new Intl.Locale("ar-u-ca-ethiopic-amete-alem").getCalendars()).toEqual(["ethioaa"]);
+        expect(new Intl.Locale("ar", { calendar: "hebrew" }).getCalendars()).toEqual(["hebrew"]);
+
+        // Invalid calendars also take precedence.
+        expect(new Intl.Locale("en-u-ca-ladybird").getCalendars()).toEqual(["ladybird"]);
+        expect(new Intl.Locale("en", { calendar: "ladybird" }).getCalendars()).toEqual([
+            "ladybird",
+        ]);
+    });
+});

+ 33 - 0
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.getCollations.js

@@ -0,0 +1,33 @@
+describe("errors", () => {
+    test("called on non-Locale object", () => {
+        expect(() => {
+            Intl.Locale.prototype.getCollations();
+        }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
+    });
+});
+
+describe("normal behavior", () => {
+    test("basic functionality", () => {
+        expect(Array.isArray(new Intl.Locale("en").getCollations())).toBeTrue();
+        expect(new Intl.Locale("en").getCollations()).toEqual(["default"]);
+
+        expect(Array.isArray(new Intl.Locale("ar").getCollations())).toBeTrue();
+        expect(new Intl.Locale("ar").getCollations()).toEqual(["default"]);
+    });
+
+    test("extension keyword overrides default data", () => {
+        expect(new Intl.Locale("en-u-co-compat").getCollations()).toEqual(["compat"]);
+        expect(new Intl.Locale("en", { collation: "compat" }).getCollations()).toEqual(["compat"]);
+
+        expect(new Intl.Locale("ar-u-co-reformed").getCollations()).toEqual(["reformed"]);
+        expect(new Intl.Locale("ar", { collation: "reformed" }).getCollations()).toEqual([
+            "reformed",
+        ]);
+
+        // Invalid getCollations() also take precedence.
+        expect(new Intl.Locale("en-u-co-ladybird").getCollations()).toEqual(["ladybird"]);
+        expect(new Intl.Locale("en", { collation: "ladybird" }).getCollations()).toEqual([
+            "ladybird",
+        ]);
+    });
+});

+ 29 - 0
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.getHourCycles.js

@@ -0,0 +1,29 @@
+describe("errors", () => {
+    test("called on non-Locale object", () => {
+        expect(() => {
+            Intl.Locale.prototype.getHourCycles();
+        }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
+    });
+});
+
+describe("normal behavior", () => {
+    test("basic functionality", () => {
+        expect(Array.isArray(new Intl.Locale("en").getHourCycles())).toBeTrue();
+        expect(new Intl.Locale("en").getHourCycles()).toContain("h12");
+
+        expect(Array.isArray(new Intl.Locale("ha").getHourCycles())).toBeTrue();
+        expect(new Intl.Locale("ha").getHourCycles()).toContain("h23");
+    });
+
+    test("extension keyword overrides default data", () => {
+        expect(new Intl.Locale("en-u-hc-h24").getHourCycles()).toEqual(["h24"]);
+        expect(new Intl.Locale("en", { hourCycle: "h24" }).getHourCycles()).toEqual(["h24"]);
+
+        expect(new Intl.Locale("ar-u-hc-h24").getHourCycles()).toEqual(["h24"]);
+        expect(new Intl.Locale("ar", { hourCycle: "h24" }).getHourCycles()).toEqual(["h24"]);
+
+        // Invalid hourCycles also take precedence when specified in the locale string. Unlike other
+        // properties, Locale("en", { hourCycle: "ladybird" }) will explicitly throw.
+        expect(new Intl.Locale("en-u-hc-ladybird").getHourCycles()).toEqual(["ladybird"]);
+    });
+});

+ 35 - 0
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.getNumberingSystems.js

@@ -0,0 +1,35 @@
+describe("errors", () => {
+    test("called on non-Locale object", () => {
+        expect(() => {
+            Intl.Locale.prototype.getNumberingSystems();
+        }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
+    });
+});
+
+describe("normal behavior", () => {
+    test("basic functionality", () => {
+        expect(Array.isArray(new Intl.Locale("en").getNumberingSystems())).toBeTrue();
+        expect(new Intl.Locale("en").getNumberingSystems()).toEqual(["latn"]);
+
+        expect(Array.isArray(new Intl.Locale("ar").getNumberingSystems())).toBeTrue();
+        expect(new Intl.Locale("ar").getNumberingSystems()).toEqual(["arab", "latn"]);
+    });
+
+    test("extension keyword overrides default data", () => {
+        expect(new Intl.Locale("en-u-nu-deva").getNumberingSystems()).toEqual(["deva"]);
+        expect(new Intl.Locale("en", { numberingSystem: "deva" }).getNumberingSystems()).toEqual([
+            "deva",
+        ]);
+
+        expect(new Intl.Locale("ar-u-nu-bali").getNumberingSystems()).toEqual(["bali"]);
+        expect(new Intl.Locale("ar", { numberingSystem: "bali" }).getNumberingSystems()).toEqual([
+            "bali",
+        ]);
+
+        // Invalid numberingSystems also take precedence.
+        expect(new Intl.Locale("en-u-nu-ladybird").getNumberingSystems()).toEqual(["ladybird"]);
+        expect(
+            new Intl.Locale("en", { numberingSystem: "ladybird" }).getNumberingSystems()
+        ).toEqual(["ladybird"]);
+    });
+});

+ 4 - 4
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.textInfo.js → Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.getTextInfo.js

@@ -1,14 +1,14 @@
 describe("errors", () => {
     test("called on non-Locale object", () => {
         expect(() => {
-            Intl.Locale.prototype.textInfo;
+            Intl.Locale.prototype.getTextInfo();
         }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
     });
 });
 
 describe("normal behavior", () => {
     test("basic functionality", () => {
-        const textInfo = new Intl.Locale("en").textInfo;
+        const textInfo = new Intl.Locale("en").getTextInfo();
 
         expect(textInfo).toBeDefined();
         expect(Object.getPrototypeOf(textInfo)).toBe(Object.prototype);
@@ -17,10 +17,10 @@ describe("normal behavior", () => {
         expect(Object.getPrototypeOf(textInfo.direction)).toBe(String.prototype);
 
         expect(textInfo.direction).toBe("ltr");
-        expect(new Intl.Locale("ar").textInfo.direction).toBe("rtl");
+        expect(new Intl.Locale("ar").getTextInfo().direction).toBe("rtl");
     });
 
     test("fallback to ltr", () => {
-        expect(new Intl.Locale("xx").textInfo.direction).toBe("ltr");
+        expect(new Intl.Locale("xx").getTextInfo().direction).toBe("ltr");
     });
 });

+ 7 - 7
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.timeZones.js → Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.getTimeZones.js

@@ -1,34 +1,34 @@
 describe("errors", () => {
     test("called on non-Locale object", () => {
         expect(() => {
-            Intl.Locale.prototype.timeZones;
+            Intl.Locale.prototype.getTimeZones();
         }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
     });
 });
 
 describe("normal behavior", () => {
     test("basic functionality", () => {
-        expect(new Intl.Locale("en").timeZones).toBeUndefined();
-        expect(new Intl.Locale("ar-Latn").timeZones).toBeUndefined();
+        expect(new Intl.Locale("en").getTimeZones()).toBeUndefined();
+        expect(new Intl.Locale("ar-Latn").getTimeZones()).toBeUndefined();
 
-        const adZones = new Intl.Locale("en-AD").timeZones;
+        const adZones = new Intl.Locale("en-AD").getTimeZones();
         expect(Array.isArray(adZones)).toBeTrue();
         expect(adZones).toEqual(["Europe/Andorra"]);
 
-        const esZones = new Intl.Locale("en-ES").timeZones;
+        const esZones = new Intl.Locale("en-ES").getTimeZones();
         expect(Array.isArray(esZones)).toBeTrue();
         expect(esZones).toEqual(["Africa/Ceuta", "Atlantic/Canary", "Europe/Madrid"]);
     });
 
     test("zone list is sorted", () => {
-        const zones = new Intl.Locale("en-US").timeZones;
+        const zones = new Intl.Locale("en-US").getTimeZones();
         const sortedZones = zones.toSorted();
 
         expect(zones).toEqual(sortedZones);
     });
 
     test("invalid region produces empty list", () => {
-        const zones = new Intl.Locale("en-ZZ").timeZones;
+        const zones = new Intl.Locale("en-ZZ").getTimeZones();
         expect(Array.isArray(zones)).toBeTrue();
         expect(zones).toEqual([]);
     });

+ 16 - 16
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.weekInfo.js → Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.getWeekInfo.js

@@ -1,14 +1,14 @@
 describe("errors", () => {
     test("called on non-Locale object", () => {
         expect(() => {
-            Intl.Locale.prototype.weekInfo;
+            Intl.Locale.prototype.getWeekInfo();
         }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
     });
 });
 
 describe("normal behavior", () => {
     test("basic functionality", () => {
-        const weekInfo = new Intl.Locale("en-US").weekInfo;
+        const weekInfo = new Intl.Locale("en-US").getWeekInfo();
 
         expect(weekInfo).toBeDefined();
         expect(Object.getPrototypeOf(weekInfo)).toBe(Object.prototype);
@@ -27,40 +27,40 @@ describe("normal behavior", () => {
     });
 
     test("regions with CLDR-specified firstDay", () => {
-        expect(new Intl.Locale("en-AG").weekInfo.firstDay).toBe(7);
-        expect(new Intl.Locale("en-SY").weekInfo.firstDay).toBe(6);
-        expect(new Intl.Locale("en-MV").weekInfo.firstDay).toBe(5);
+        expect(new Intl.Locale("en-AG").getWeekInfo().firstDay).toBe(7);
+        expect(new Intl.Locale("en-SY").getWeekInfo().firstDay).toBe(6);
+        expect(new Intl.Locale("en-MV").getWeekInfo().firstDay).toBe(5);
     });
 
     test("firstDay falls back to default region 001", () => {
-        expect(new Intl.Locale("en-AC").weekInfo.firstDay).toBe(1);
+        expect(new Intl.Locale("en-AC").getWeekInfo().firstDay).toBe(1);
     });
 
     test("regions with CLDR-specified weekend", () => {
-        expect(new Intl.Locale("en-AF").weekInfo.weekend).toEqual([4, 5]);
-        expect(new Intl.Locale("en-IN").weekInfo.weekend).toEqual([7]);
-        expect(new Intl.Locale("en-YE").weekInfo.weekend).toEqual([5, 6]);
+        expect(new Intl.Locale("en-AF").getWeekInfo().weekend).toEqual([4, 5]);
+        expect(new Intl.Locale("en-IN").getWeekInfo().weekend).toEqual([7]);
+        expect(new Intl.Locale("en-YE").getWeekInfo().weekend).toEqual([5, 6]);
     });
 
     test("weekend falls back to default region 001", () => {
-        expect(new Intl.Locale("en-AC").weekInfo.weekend).toEqual([6, 7]);
+        expect(new Intl.Locale("en-AC").getWeekInfo().weekend).toEqual([6, 7]);
     });
 
     test("regions with CLDR-specified minimalDays", () => {
-        expect(new Intl.Locale("en-AD").weekInfo.minimalDays).toBe(4);
-        expect(new Intl.Locale("en-CZ").weekInfo.minimalDays).toBe(4);
+        expect(new Intl.Locale("en-AD").getWeekInfo().minimalDays).toBe(4);
+        expect(new Intl.Locale("en-CZ").getWeekInfo().minimalDays).toBe(4);
     });
 
     test("minimalDays falls back to default region 001", () => {
-        expect(new Intl.Locale("en-AC").weekInfo.minimalDays).toBe(1);
+        expect(new Intl.Locale("en-AC").getWeekInfo().minimalDays).toBe(1);
     });
 
     test("likely regional subtags are added to locales without a region", () => {
-        const defaultRegion = new Intl.Locale("en-001").weekInfo;
+        const defaultRegion = new Intl.Locale("en-001").getWeekInfo();
 
         // "en" expands to "en-US" when likely subtags are added.
-        const en = new Intl.Locale("en").weekInfo;
-        const enUS = new Intl.Locale("en-US").weekInfo;
+        const en = new Intl.Locale("en").getWeekInfo();
+        const enUS = new Intl.Locale("en-US").getWeekInfo();
 
         expect(en).toEqual(enUS);
         expect(en).not.toEqual(defaultRegion);

+ 0 - 29
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.hourCycles.js

@@ -1,29 +0,0 @@
-describe("errors", () => {
-    test("called on non-Locale object", () => {
-        expect(() => {
-            Intl.Locale.prototype.hourCycles;
-        }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
-    });
-});
-
-describe("normal behavior", () => {
-    test("basic functionality", () => {
-        expect(Array.isArray(new Intl.Locale("en").hourCycles)).toBeTrue();
-        expect(new Intl.Locale("en").hourCycles).toContain("h12");
-
-        expect(Array.isArray(new Intl.Locale("ha").hourCycles)).toBeTrue();
-        expect(new Intl.Locale("ha").hourCycles).toContain("h23");
-    });
-
-    test("extension keyword overrides default data", () => {
-        expect(new Intl.Locale("en-u-hc-h24").hourCycles).toEqual(["h24"]);
-        expect(new Intl.Locale("en", { hourCycle: "h24" }).hourCycles).toEqual(["h24"]);
-
-        expect(new Intl.Locale("ar-u-hc-h24").hourCycles).toEqual(["h24"]);
-        expect(new Intl.Locale("ar", { hourCycle: "h24" }).hourCycles).toEqual(["h24"]);
-
-        // Invalid hourCycles also take precedence when specified in the locale string. Unlike other
-        // properties, Locale("en", { hourCycle: "ladybird" }) will explicitly throw.
-        expect(new Intl.Locale("en-u-hc-ladybird").hourCycles).toEqual(["ladybird"]);
-    });
-});

+ 0 - 35
Userland/Libraries/LibJS/Tests/builtins/Intl/Locale/Locale.prototype.numberingSystems.js

@@ -1,35 +0,0 @@
-describe("errors", () => {
-    test("called on non-Locale object", () => {
-        expect(() => {
-            Intl.Locale.prototype.numberingSystems;
-        }).toThrowWithMessage(TypeError, "Not an object of type Intl.Locale");
-    });
-});
-
-describe("normal behavior", () => {
-    test("basic functionality", () => {
-        expect(Array.isArray(new Intl.Locale("en").numberingSystems)).toBeTrue();
-        expect(new Intl.Locale("en").numberingSystems).toEqual(["latn"]);
-
-        expect(Array.isArray(new Intl.Locale("ar").numberingSystems)).toBeTrue();
-        expect(new Intl.Locale("ar").numberingSystems).toEqual(["arab", "latn"]);
-    });
-
-    test("extension keyword overrides default data", () => {
-        expect(new Intl.Locale("en-u-nu-deva").numberingSystems).toEqual(["deva"]);
-        expect(new Intl.Locale("en", { numberingSystem: "deva" }).numberingSystems).toEqual([
-            "deva",
-        ]);
-
-        expect(new Intl.Locale("ar-u-nu-bali").numberingSystems).toEqual(["bali"]);
-        expect(new Intl.Locale("ar", { numberingSystem: "bali" }).numberingSystems).toEqual([
-            "bali",
-        ]);
-
-        // Invalid numberingSystems also take precedence.
-        expect(new Intl.Locale("en-u-nu-ladybird").numberingSystems).toEqual(["ladybird"]);
-        expect(new Intl.Locale("en", { numberingSystem: "ladybird" }).numberingSystems).toEqual([
-            "ladybird",
-        ]);
-    });
-});