[Intl] Impl LocaleInfo PR 63

https://github.com/tc39/proposal-intl-locale-info/pull/63

Sort collation code alphabetically before return.

Bug: v8:13542
Change-Id: I1c7df69af483a96a1fc7625b11c2b850edc59283
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4094503
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84857}
This commit is contained in:
Frank Tang 2022-12-14 13:15:42 -08:00 committed by V8 LUCI CQ
parent f0dfa877b2
commit 6bf3344f5d
3 changed files with 16 additions and 1 deletions

View File

@ -531,7 +531,7 @@ MaybeHandle<JSArray> JSLocale::Collations(Isolate* isolate,
icu::Locale icu_locale(*(locale->icu_locale().raw()));
return GetKeywordValuesFromLocale<icu::Collator>(
isolate, "collations", "co", icu_locale, Intl::RemoveCollation, true,
false);
true);
}
MaybeHandle<JSArray> JSLocale::HourCycles(Isolate* isolate,

View File

@ -292,3 +292,17 @@ function assertLanguageTag(child, parent) {
fail(child, parent, 'language tag comparison');
}
}
function assertArrayEquals(expected, found, name_opt) {
var start = "";
if (name_opt) {
start = name_opt + " - ";
}
assertEquals(expected.length, found.length, start + "array length");
if (expected.length === found.length) {
for (var i = 0; i < expected.length; ++i) {
assertEquals(expected[i], found[i],
start + "array element at index " + i);
}
}
}

View File

@ -15,5 +15,6 @@ for (var i = 0; i < a_to_z.length; i++) {
locale + ".collations [" + locale.collations +
"] does not meet 'type: alphanum{3,8}(sep alphanum{3,8})*'");
});
assertArrayEquals(locale.collations, locale.collations.sort());
}
}