Bug 1927706 - Part 13: Update expected test results for non-SpiderMonkey code. r=platform-i18n-reviewers,gregtatum

The "ar" locale without a region subtag now defaults to Latin script. Replace with "ar-EG"
to ensure we test Arabic script, too.

Change "space-cluster-2.html" to use U+0311 INVERTED BREVE to avoid getting the
Cyrillic variant glyph for BREVE in Consolas. See Bug 1927706, comment #24 for a
detailled comment why updating ICU to Unicode 16 broke this test case on Windows.

Differential Revision: https://phabricator.services.mozilla.com/D227214
This commit is contained in:
André Bargull 2024-10-31 10:26:31 +00:00
parent 2b46da0d08
commit 1439fb99ee
8 changed files with 39 additions and 19 deletions

View File

@ -59,7 +59,7 @@ TEST(IntlDateTimeFormat, Style_ar_utf8)
DateTimeFormat::StyleBag style;
style.time = Some(DateTimeFormat::Style::Medium);
auto dtFormat = testStyle("ar", style);
auto dtFormat = testStyle("ar-EG", style);
TestBuffer<char> buffer;
dtFormat->TryFormat(DATE, buffer).unwrap();
@ -71,7 +71,7 @@ TEST(IntlDateTimeFormat, Style_ar_utf16)
DateTimeFormat::StyleBag style;
style.time = Some(DateTimeFormat::Style::Medium);
auto dtFormat = testStyle("ar", style);
auto dtFormat = testStyle("ar-EG", style);
TestBuffer<char16_t> buffer;
dtFormat->TryFormat(DATE, buffer).unwrap();
@ -567,6 +567,8 @@ TEST(IntlDateTimeFormat, TryFormatToParts)
TEST(IntlDateTimeFormat, SetStartTimeIfGregorian)
{
using namespace std::literals;
DateTimeFormat::StyleBag style{};
style.date = Some(DateTimeFormat::Style::Long);
@ -595,27 +597,40 @@ TEST(IntlDateTimeFormat, SetStartTimeIfGregorian)
MakeStringSpan(locale), style, gen.get(), timeZone)
.unwrap();
const char* Dec22_1581;
const char* Jan01_1582;
const char* Jan01_1583;
if (locale == "en-US-u-ca-iso8601"sv) {
Dec22_1581 = "1581 December 22";
Jan01_1582 = "1582 January 1";
Jan01_1583 = "1583 January 1";
} else {
Dec22_1581 = "December 22, 1581";
Jan01_1582 = "January 1, 1582";
Jan01_1583 = "January 1, 1583";
}
TestBuffer<char> buffer;
// Before the default Gregorian change date, so interpreted in the Julian
// calendar, which is December 22, 1581.
dtFormat->TryFormat(FirstJanuary1582, buffer).unwrap();
ASSERT_TRUE(buffer.verboseMatches("December 22, 1581"));
ASSERT_TRUE(buffer.verboseMatches(Dec22_1581));
// After default Gregorian change date, so January 1, 1583.
dtFormat->TryFormat(FirstJanuary1582 + oneYear, buffer).unwrap();
ASSERT_TRUE(buffer.verboseMatches("January 1, 1583"));
ASSERT_TRUE(buffer.verboseMatches(Jan01_1583));
// Adjust the start time to use a proleptic Gregorian calendar.
dtFormat->SetStartTimeIfGregorian(StartOfTime);
// Now interpreted in proleptic Gregorian calendar at January 1, 1582.
dtFormat->TryFormat(FirstJanuary1582, buffer).unwrap();
ASSERT_TRUE(buffer.verboseMatches("January 1, 1582"));
ASSERT_TRUE(buffer.verboseMatches(Jan01_1582));
// Still January 1, 1583.
dtFormat->TryFormat(FirstJanuary1582 + oneYear, buffer).unwrap();
ASSERT_TRUE(buffer.verboseMatches("January 1, 1583"));
ASSERT_TRUE(buffer.verboseMatches(Jan01_1583));
}
}
} // namespace mozilla::intl

View File

@ -42,12 +42,17 @@ TEST(IntlLocaleCanonicalizer, CanonicalizeICULevel1)
// Removes the .utf8 ends
CheckLocaleResult(ascii, "ar-MA.utf8", "ar_MA");
// Allows valid ascii inputs
CheckLocaleResult(
ascii,
"abcdefghijlkmnopqrstuvwxyzABCDEFGHIJLKMNOPQRSTUVWXYZ-_.0123456789",
"abcdefghijlkmnopqrstuvwxyzabcdefghijlkmnopqrstuvwxyz__");
CheckLocaleResult(ascii, "exotic ascii:", "exotic ascii:");
// Rejects non parseable ASCII inputs.
ASSERT_EQ(
LocaleCanonicalizer::CanonicalizeICULevel1(
"abcdefghijlkmnopqrstuvwxyzABCDEFGHIJLKMNOPQRSTUVWXYZ-_.0123456789",
ascii)
.unwrapErr(),
ICUError::InternalError);
ASSERT_EQ(
LocaleCanonicalizer::CanonicalizeICULevel1("exotic ascii:", ascii)
.unwrapErr(),
ICUError::InternalError);
// Does not accept non-ascii inputs.
ASSERT_EQ(LocaleCanonicalizer::CanonicalizeICULevel1("👍", ascii).unwrapErr(),

View File

@ -27,7 +27,7 @@ TEST(IntlNumberFormat, Basic)
ASSERT_EQ(std::u16string_view(res16), u"1,234.56");
UniquePtr<NumberFormat> nfAr =
NumberFormat::TryCreate("ar", options).unwrap();
NumberFormat::TryCreate("ar-EG", options).unwrap();
ASSERT_TRUE(nfAr->format(1234.56, buf8).isOk());
ASSERT_EQ(buf8.get_string_view(), "١٬٢٣٤٫٥٦");
ASSERT_TRUE(nfAr->format(1234.56, buf16).isOk());

View File

@ -13,7 +13,7 @@ TEST(IntlNumberingSystem, GetName)
auto numbers_en = NumberingSystem::TryCreate("en").unwrap();
ASSERT_EQ(numbers_en->GetName().unwrap(), MakeStringSpan("latn"));
auto numbers_ar = NumberingSystem::TryCreate("ar").unwrap();
auto numbers_ar = NumberingSystem::TryCreate("ar-EG").unwrap();
ASSERT_EQ(numbers_ar->GetName().unwrap(), MakeStringSpan("arab"));
auto numbers_ff_Adlm = NumberingSystem::TryCreate("ff-Adlm").unwrap();

View File

@ -38,7 +38,7 @@ TEST(IntlRelativeTimeFormat, Basic)
rtf->format(1.2, RelativeTimeFormat::FormatUnit::Day, buf16).isOk());
ASSERT_EQ(buf16.get_string_view(), u"dentro de 1,2 días");
res = RelativeTimeFormat::TryCreate("ar", options);
res = RelativeTimeFormat::TryCreate("ar-EG", options);
ASSERT_TRUE(res.isOk());
rtf = res.unwrap();
buf8.clear();

View File

@ -18,8 +18,8 @@ TEST(IntlScript, GetExtensions)
ASSERT_EQ(Script(extensions[0]), Script::COMMON);
}
// 0x0300..0x0341 are Inherited.
for (char32_t ch = 0x300; ch < 0x0341; ch++) {
// 0x0332..0x0341 are Inherited.
for (char32_t ch = 0x332; ch < 0x0342; ch++) {
ASSERT_TRUE(UnicodeProperties::GetExtensions(ch, extensions).isOk());
ASSERT_EQ(extensions.length(), 1u);
ASSERT_EQ(Script(extensions[0]), Script::INHERITED);

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<body>
Each diacritic should be on a separate line:
<div style="margin: 1em; line-height: 1.5em; font-family: monospace;">&#x302;<br>&#x304;<br>&#x305;<br>&#x306;<br>&#x307;
<div style="margin: 1em; line-height: 1.5em; font-family: monospace;">&#x302;<br>&#x304;<br>&#x305;<br>&#x311;<br>&#x307;

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<body>
Each diacritic should be on a separate line:
<div style="width: 0; margin: 1em; line-height: 1.5em; font-family: monospace;">&#x302; &#x304; &#x305; &#x306; &#x307;
<div style="width: 0; margin: 1em; line-height: 1.5em; font-family: monospace;">&#x302; &#x304; &#x305; &#x311; &#x307;