From 1439fb99eed50bcba24229c3d6a06311d6bca03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bargull?= Date: Thu, 31 Oct 2024 10:26:31 +0000 Subject: [PATCH] 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 --- intl/components/gtest/TestDateTimeFormat.cpp | 27 ++++++++++++++----- .../gtest/TestLocaleCanonicalizer.cpp | 17 +++++++----- intl/components/gtest/TestNumberFormat.cpp | 2 +- intl/components/gtest/TestNumberingSystem.cpp | 2 +- .../gtest/TestRelativeTimeFormat.cpp | 2 +- intl/components/gtest/TestScript.cpp | 4 +-- .../line-breaking/space-cluster-2-ref.html | 2 +- .../line-breaking/space-cluster-2.html | 2 +- 8 files changed, 39 insertions(+), 19 deletions(-) diff --git a/intl/components/gtest/TestDateTimeFormat.cpp b/intl/components/gtest/TestDateTimeFormat.cpp index 057e26ea1340..6d9e0318382b 100644 --- a/intl/components/gtest/TestDateTimeFormat.cpp +++ b/intl/components/gtest/TestDateTimeFormat.cpp @@ -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 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 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 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 diff --git a/intl/components/gtest/TestLocaleCanonicalizer.cpp b/intl/components/gtest/TestLocaleCanonicalizer.cpp index de1d7d13539a..ffacb77d7145 100644 --- a/intl/components/gtest/TestLocaleCanonicalizer.cpp +++ b/intl/components/gtest/TestLocaleCanonicalizer.cpp @@ -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(), diff --git a/intl/components/gtest/TestNumberFormat.cpp b/intl/components/gtest/TestNumberFormat.cpp index e13ca7fc36cb..a5e1f3aaa641 100644 --- a/intl/components/gtest/TestNumberFormat.cpp +++ b/intl/components/gtest/TestNumberFormat.cpp @@ -27,7 +27,7 @@ TEST(IntlNumberFormat, Basic) ASSERT_EQ(std::u16string_view(res16), u"1,234.56"); UniquePtr 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()); diff --git a/intl/components/gtest/TestNumberingSystem.cpp b/intl/components/gtest/TestNumberingSystem.cpp index c6f15b6559c7..d159ae073353 100644 --- a/intl/components/gtest/TestNumberingSystem.cpp +++ b/intl/components/gtest/TestNumberingSystem.cpp @@ -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(); diff --git a/intl/components/gtest/TestRelativeTimeFormat.cpp b/intl/components/gtest/TestRelativeTimeFormat.cpp index eced3961d7e4..33ddf5b72c29 100644 --- a/intl/components/gtest/TestRelativeTimeFormat.cpp +++ b/intl/components/gtest/TestRelativeTimeFormat.cpp @@ -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(); diff --git a/intl/components/gtest/TestScript.cpp b/intl/components/gtest/TestScript.cpp index 72d8cd108722..030940706c5a 100644 --- a/intl/components/gtest/TestScript.cpp +++ b/intl/components/gtest/TestScript.cpp @@ -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); diff --git a/layout/reftests/line-breaking/space-cluster-2-ref.html b/layout/reftests/line-breaking/space-cluster-2-ref.html index c7fb7ac99e32..50ffc6ad0788 100644 --- a/layout/reftests/line-breaking/space-cluster-2-ref.html +++ b/layout/reftests/line-breaking/space-cluster-2-ref.html @@ -1,4 +1,4 @@ Each diacritic should be on a separate line: -
̂
̄
̅
̆
̇ +
̂
̄
̅
̑
̇ diff --git a/layout/reftests/line-breaking/space-cluster-2.html b/layout/reftests/line-breaking/space-cluster-2.html index a1eb7f9e3f10..fa5a304ab903 100644 --- a/layout/reftests/line-breaking/space-cluster-2.html +++ b/layout/reftests/line-breaking/space-cluster-2.html @@ -1,4 +1,4 @@ Each diacritic should be on a separate line: -
̂ ̄ ̅ ̆ ̇ +
̂ ̄ ̅ ̑ ̇