From 643f3ec9f0171656bb84004d9add731e8e28d697 Mon Sep 17 00:00:00 2001 From: EgorBo Date: Sat, 18 Jul 2020 14:47:23 +0300 Subject: [PATCH 1/3] Bump ICU, disable some tests for Browser --- eng/Version.Details.xml | 4 +- eng/Versions.props | 2 +- .../CultureInfo/CultureInfoEnglishName.cs | 14 +++++- .../CultureInfo/CultureInfoNativeName.cs | 14 +++++- ...FormatInfoAbbreviatedMonthGenitiveNames.cs | 4 ++ .../DateTimeFormatInfoTests.cs | 9 +++- .../NumberFormatInfoNumberGroupSizes.cs | 4 +- .../System/Globalization/RegionInfoTests.cs | 50 ++++++++++++++++--- 8 files changed, 84 insertions(+), 17 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 098240ee26cbd9..fb10f7bae55e84 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -4,9 +4,9 @@ https://github.com/dotnet/standard cfe95a23647c7de1fe1a349343115bd7720d6949 - + https://github.com/dotnet/icu - 7247fa0d9e8faee2cceee6f04856b2c447f41bca + aa6975c3e79dfc3bad4bd0d00eba94f0b0611a3a diff --git a/eng/Versions.props b/eng/Versions.props index 8366710273c7d5..f99e6fcfa350cb 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -118,7 +118,7 @@ 5.0.0-preview.3.20363.5 - 5.0.0-preview.8.20365.1 + 5.0.0-preview.8.20367.1 9.0.1-alpha.1.20356.1 9.0.1-alpha.1.20356.1 diff --git a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoEnglishName.cs b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoEnglishName.cs index 23c2032c51cd41..fdb6e4b189fcee 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoEnglishName.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoEnglishName.cs @@ -11,8 +11,18 @@ public class CultureInfoEnglishName public static IEnumerable EnglishName_TestData() { yield return new object[] { CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.EnglishName }; - yield return new object[] { "en-US", "English (United States)" }; - yield return new object[] { "fr-FR", "French (France)" }; + + if (PlatformDetection.IsNotBrowser) + { + yield return new object[] { "en-US", "English (United States)" }; + yield return new object[] { "fr-FR", "French (France)" }; + } + else + { + // Browser's ICU doesn't contain CultureInfo.EnglishName + yield return new object[] { "en-US", "en (US)" }; + yield return new object[] { "fr-FR", "fr (FR)" }; + } } [Theory] diff --git a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoNativeName.cs b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoNativeName.cs index b97a645b8b2a57..58429b132138cc 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoNativeName.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoNativeName.cs @@ -11,8 +11,18 @@ public class CultureInfoNativeName public static IEnumerable NativeName_TestData() { yield return new object[] { CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.NativeName }; - yield return new object[] { "en-US", "English (United States)" }; - yield return new object[] { "en-CA", "English (Canada)" }; + + if (PlatformDetection.IsNotBrowser) + { + yield return new object[] { "en-US", "English (United States)" }; + yield return new object[] { "en-CA", "English (Canada)" }; + } + else + { + // Browser's ICU doesn't contain CultureInfo.NativeName + yield return new object[] { "en-US", "en (US)" }; + yield return new object[] { "en-CA", "en (CA)" }; + } } [Theory] diff --git a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs index 4e49bdd154ee69..b69253ec7f60bb 100644 --- a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs +++ b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs @@ -110,6 +110,10 @@ public void TestAbbreviatedGenitiveNamesWithAllCultures() } } + // TODO: Investigate why Browser's ICU fails on ja (ja-JP) locale here. + if (PlatformDetection.IsBrowser && ci.Name.StartsWith("ja")) + continue; + // ParseExact should succeeded all the time even with non genitive cases . Assert.Equal(dt, DateTime.ParseExact(formattedDate, "d MMM yyyy", ci)); } diff --git a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs index 1689c9e312d2db..bda34e38fa731b 100644 --- a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs +++ b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs @@ -66,7 +66,12 @@ public void NativeCalendarName_Get_ReturnsExpected(DateTimeFormatInfo dtfi, Cale try { dtfi.Calendar = calendar; - Assert.Equal(nativeCalendarName, dtfi.NativeCalendarName); + + if (PlatformDetection.IsNotBrowser) + { + // Browser's ICU doesn't contain NativeCalendarName, + Assert.Equal(nativeCalendarName, dtfi.NativeCalendarName); + } } catch { @@ -162,6 +167,8 @@ public void Months_GetHebrew_ReturnsExpected() } [Fact] + // TODO: Investigate why Browser's ICU fails + [ActiveIssue("https://github.com/dotnet/runtime/issues/39285", TestPlatforms.Browser)] public void TestFirstYearOfJapaneseEra() { DateTimeFormatInfo jpnFormat = new CultureInfo("ja-JP").DateTimeFormat; diff --git a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoNumberGroupSizes.cs b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoNumberGroupSizes.cs index 045d3e0b585be7..62ae02d3aa4a4c 100644 --- a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoNumberGroupSizes.cs +++ b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoNumberGroupSizes.cs @@ -13,8 +13,8 @@ public static IEnumerable NumberGroupSizes_TestData() yield return new object[] { NumberFormatInfo.InvariantInfo, new int[] { 3 } }; yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, new int[] { 3 } }; - // Culture does not exist on Windows 7 - if (!PlatformDetection.IsWindows7) + // Culture does not exist on Windows 7 and in Browser's ICU + if (!PlatformDetection.IsWindows7 && PlatformDetection.IsNotBrowser) { yield return new object[] { CultureInfo.GetCultureInfo("ur-IN").NumberFormat, NumberFormatInfoData.UrINNumberGroupSizes() }; } diff --git a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs index dd99a40e94ca83..86c657f80a4006 100644 --- a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs +++ b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs @@ -90,20 +90,51 @@ public void DisplayName(string name, string expected) } } + public static IEnumerable NativeName_TestData() + { + if (PlatformDetection.IsNotBrowser) + { + yield return new object[] { "GB", "United Kingdom" }; + yield return new object[] { "SE", "Sverige" }; + yield return new object[] { "FR", "France" }; + } + else + { + // Browser's ICU doesn't contain RegionInfo.NativeName + yield return new object[] { "GB", "GB" }; + yield return new object[] { "SE", "SE" }; + yield return new object[] { "FR", "FR" }; + } + } + [Theory] - [InlineData("GB", "United Kingdom")] - [InlineData("SE", "Sverige")] - [InlineData("FR", "France")] + [MemberData(nameof(NativeName_TestData))] public void NativeName(string name, string expected) { Assert.Equal(expected, new RegionInfo(name).NativeName); } + public static IEnumerable EnglishName_TestData() + { + if (PlatformDetection.IsNotBrowser) + { + yield return new object[] { "en-US", new string[] { "United States" } }; + yield return new object[] { "US", new string[] { "United States" } }; + yield return new object[] { "zh-CN", new string[] { "China", "People's Republic of China", "China mainland" }}; + yield return new object[] { "CN", new string[] { "China", "People's Republic of China", "China mainland" } }; + } + else + { + // Browser's ICU doesn't contain RegionInfo.EnglishName + yield return new object[] { "en-US", new string[] { "US" } }; + yield return new object[] { "US", new string[] { "US" } }; + yield return new object[] { "zh-CN", new string[] { "CN" }}; + yield return new object[] { "CN", new string[] { "CN" } }; + } + } + [Theory] - [InlineData("en-US", new string[] { "United States" })] - [InlineData("US", new string[] { "United States" })] - [InlineData("zh-CN", new string[] { "China", "People's Republic of China", "China mainland" })] - [InlineData("CN", new string[] { "China", "People's Republic of China", "China mainland" })] + [MemberData(nameof(EnglishName_TestData))] public void EnglishName(string name, string[] expected) { string result = new RegionInfo(name).EnglishName; @@ -115,6 +146,11 @@ public void EnglishName(string name, string[] expected) [InlineData("zh-CN", true)] public void IsMetric(string name, bool expected) { + if (PlatformDetection.IsBrowser) + { + // Browser's ICU always return true for IsMetric + expected = true; + } Assert.Equal(expected, new RegionInfo(name).IsMetric); } From ed6d0197470873a5eae70876f37c0a1b17f85e4b Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 20 Jul 2020 16:42:48 +0300 Subject: [PATCH 2/3] uncomment some tests --- .../DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs | 4 ---- .../tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs | 2 -- .../tests/System/Globalization/RegionInfoTests.cs | 5 ----- 3 files changed, 11 deletions(-) diff --git a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs index b69253ec7f60bb..4e49bdd154ee69 100644 --- a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs +++ b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoAbbreviatedMonthGenitiveNames.cs @@ -110,10 +110,6 @@ public void TestAbbreviatedGenitiveNamesWithAllCultures() } } - // TODO: Investigate why Browser's ICU fails on ja (ja-JP) locale here. - if (PlatformDetection.IsBrowser && ci.Name.StartsWith("ja")) - continue; - // ParseExact should succeeded all the time even with non genitive cases . Assert.Equal(dt, DateTime.ParseExact(formattedDate, "d MMM yyyy", ci)); } diff --git a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs index bda34e38fa731b..52cda26a787aef 100644 --- a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs +++ b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs @@ -167,8 +167,6 @@ public void Months_GetHebrew_ReturnsExpected() } [Fact] - // TODO: Investigate why Browser's ICU fails - [ActiveIssue("https://github.com/dotnet/runtime/issues/39285", TestPlatforms.Browser)] public void TestFirstYearOfJapaneseEra() { DateTimeFormatInfo jpnFormat = new CultureInfo("ja-JP").DateTimeFormat; diff --git a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs index 86c657f80a4006..2cb86dc56da24c 100644 --- a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs +++ b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs @@ -146,11 +146,6 @@ public void EnglishName(string name, string[] expected) [InlineData("zh-CN", true)] public void IsMetric(string name, bool expected) { - if (PlatformDetection.IsBrowser) - { - // Browser's ICU always return true for IsMetric - expected = true; - } Assert.Equal(expected, new RegionInfo(name).IsMetric); } From 66248ee77abbafd1b86ba1f36ae075178333c23f Mon Sep 17 00:00:00 2001 From: EgorBo Date: Mon, 20 Jul 2020 17:25:16 +0300 Subject: [PATCH 3/3] bump icu nuget --- eng/Version.Details.xml | 4 ++-- eng/Versions.props | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index fb10f7bae55e84..0d7aad96f5897b 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -4,9 +4,9 @@ https://github.com/dotnet/standard cfe95a23647c7de1fe1a349343115bd7720d6949 - + https://github.com/dotnet/icu - aa6975c3e79dfc3bad4bd0d00eba94f0b0611a3a + 797c523dd8d75096319f3591958f703b8d74d04b diff --git a/eng/Versions.props b/eng/Versions.props index f99e6fcfa350cb..94c0d597cd5715 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -118,7 +118,7 @@ 5.0.0-preview.3.20363.5 - 5.0.0-preview.8.20367.1 + 5.0.0-preview.8.20370.1 9.0.1-alpha.1.20356.1 9.0.1-alpha.1.20356.1