From ca76623e09762ca4cb031024a7e6a694a79ad266 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Fri, 24 Apr 2020 17:47:53 -0700 Subject: [PATCH 1/4] Fix coreclr Test570 due to ICU on Windows feature --- src/coreclr/tests/src/Common/CoreCLRTestLibrary/Utilities.cs | 5 +++++ src/coreclr/tests/src/Regressions/coreclr/0570/test570.cs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/coreclr/tests/src/Common/CoreCLRTestLibrary/Utilities.cs b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/Utilities.cs index bc2d55bffb08dd..f88d0f6247bfdd 100644 --- a/src/coreclr/tests/src/Common/CoreCLRTestLibrary/Utilities.cs +++ b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/Utilities.cs @@ -73,6 +73,11 @@ public static bool Verbose // Windows 10 October 2018 Update public static bool IsWindows10Version1809OrGreater => IsWindows && GetWindowsVersion() == 10 && GetWindowsMinorVersion() == 0 && GetWindowsBuildNumber() >= 17763; + + // >= Windows 10 May 2019 Update (19H1) + public static bool IsWindows10Version1903OrGreater => + IsWindows && GetWindowsVersion() == 10 && GetWindowsMinorVersion() == 0 && GetWindowsBuildNumber() >= 18362; + public static bool IsWindowsIoTCore { get diff --git a/src/coreclr/tests/src/Regressions/coreclr/0570/test570.cs b/src/coreclr/tests/src/Regressions/coreclr/0570/test570.cs index ce572f0a319f9b..1f2b7937829a71 100644 --- a/src/coreclr/tests/src/Regressions/coreclr/0570/test570.cs +++ b/src/coreclr/tests/src/Regressions/coreclr/0570/test570.cs @@ -10,7 +10,7 @@ public static int Main() { int retVal = 100; int numDigits = 2; - if (!TestLibrary.Utilities.IsWindows) + if (!TestLibrary.Utilities.IsWindows || TestLibrary.Utilities.IsWindows10Version1903OrGreater) { numDigits = 3; } From 3254b87e11b686cc99ec4a6f26be57c3487c0272 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Fri, 24 Apr 2020 19:31:06 -0700 Subject: [PATCH 2/4] PR Feedback, remove test and add testcase to PercentDecimalDigits tests --- .../Common/CoreCLRTestLibrary/Utilities.cs | 4 -- .../Regressions/coreclr/0570/Test570.csproj | 14 ------- .../src/Regressions/coreclr/0570/test570.cs | 42 ------------------- .../NumberFormatInfoPercentDecimalDigits.cs | 14 +++++-- 4 files changed, 11 insertions(+), 63 deletions(-) delete mode 100644 src/coreclr/tests/src/Regressions/coreclr/0570/Test570.csproj delete mode 100644 src/coreclr/tests/src/Regressions/coreclr/0570/test570.cs diff --git a/src/coreclr/tests/src/Common/CoreCLRTestLibrary/Utilities.cs b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/Utilities.cs index f88d0f6247bfdd..e596d551a45db8 100644 --- a/src/coreclr/tests/src/Common/CoreCLRTestLibrary/Utilities.cs +++ b/src/coreclr/tests/src/Common/CoreCLRTestLibrary/Utilities.cs @@ -73,10 +73,6 @@ public static bool Verbose // Windows 10 October 2018 Update public static bool IsWindows10Version1809OrGreater => IsWindows && GetWindowsVersion() == 10 && GetWindowsMinorVersion() == 0 && GetWindowsBuildNumber() >= 17763; - - // >= Windows 10 May 2019 Update (19H1) - public static bool IsWindows10Version1903OrGreater => - IsWindows && GetWindowsVersion() == 10 && GetWindowsMinorVersion() == 0 && GetWindowsBuildNumber() >= 18362; public static bool IsWindowsIoTCore { diff --git a/src/coreclr/tests/src/Regressions/coreclr/0570/Test570.csproj b/src/coreclr/tests/src/Regressions/coreclr/0570/Test570.csproj deleted file mode 100644 index 80fe7cd837af36..00000000000000 --- a/src/coreclr/tests/src/Regressions/coreclr/0570/Test570.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - Exe - true - BuildAndRun - 1 - - - - - - - - diff --git a/src/coreclr/tests/src/Regressions/coreclr/0570/test570.cs b/src/coreclr/tests/src/Regressions/coreclr/0570/test570.cs deleted file mode 100644 index 1f2b7937829a71..00000000000000 --- a/src/coreclr/tests/src/Regressions/coreclr/0570/test570.cs +++ /dev/null @@ -1,42 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. -using System; -using System.Globalization; - -public class Test570 -{ - public static int Main() - { - int retVal = 100; - int numDigits = 2; - if (!TestLibrary.Utilities.IsWindows || TestLibrary.Utilities.IsWindows10Version1903OrGreater) - { - numDigits = 3; - } - - try - { - CultureInfo enUS = new CultureInfo("en-US"); - TestLibrary.Logging.WriteLine("enUS.NumberFormat.NumberDecimalDigits=" + enUS.NumberFormat.NumberDecimalDigits.ToString()); - if (enUS.NumberFormat.NumberDecimalDigits != numDigits) - { - TestLibrary.Logging.WriteLine("Error: enUS.NumberFormat.NumberDecimalDigits=" + enUS.NumberFormat.NumberDecimalDigits.ToString() + ", expected " + numDigits.ToString()); - retVal = 0; - } - TestLibrary.Logging.WriteLine("enUS.NumberFormat.PercentDecimalDigits=" + enUS.NumberFormat.PercentDecimalDigits.ToString()); - if (enUS.NumberFormat.PercentDecimalDigits != numDigits) - { - TestLibrary.Logging.WriteLine("Error: enUS.NumberFormat.PercentDecimalDigits=" + enUS.NumberFormat.PercentDecimalDigits.ToString() + ", expected " + numDigits.ToString()); - retVal = 0; - } - } - catch (Exception ex) - { - TestLibrary.Logging.WriteLine("Exception cought in main:"+ex.Message); - retVal = 0; - } - return retVal; - } - -} diff --git a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs index 30741388ba8426..772e158530c694 100644 --- a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs +++ b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs @@ -8,10 +8,18 @@ namespace System.Globalization.Tests { public class NumberFormatInfoPercentDecimalDigits { - [Fact] - public void PercentDecimalDigits_GetInvariantInfo_ReturnsExpected() + public static IEnumerable PercentDecimalDigits_TestData() + { + yield return new object[] { NumberFormatInfo.InvariantInfo, 2, 2 }; + yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, 2, 3 }; + } + + [Theory] + [MemberData(nameof(PercentDecimalDigits_TestData))] + public void PercentDecimalDigits_Get_ReturnsExpected(NumberFormatInfo format, int expectedNls, int expectedIcu) { - Assert.Equal(2, NumberFormatInfo.InvariantInfo.PercentDecimalDigits); + int expected = PlatformDetection.IsNlsGlobalization ? expectedNls : expectedIcu; + Assert.Equal(expected, format.PercentDecimalDigits); } [Theory] From 07991e870ed9b3094ef9bd6c4c7d45d888577beb Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Fri, 24 Apr 2020 20:24:01 -0700 Subject: [PATCH 3/4] Fix test build --- .../NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs index 772e158530c694..aeb2240eb7b827 100644 --- a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs +++ b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +using System.Collections; using Xunit; namespace System.Globalization.Tests From a44efb13dce813c7b867c18b975b496e54f6ae48 Mon Sep 17 00:00:00 2001 From: Santiago Fernandez Madero Date: Fri, 24 Apr 2020 21:08:21 -0700 Subject: [PATCH 4/4] Actually fix the build --- .../NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs index aeb2240eb7b827..8bbe772d6a22e3 100644 --- a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs +++ b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoPercentDecimalDigits.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections; +using System.Collections.Generic; using Xunit; namespace System.Globalization.Tests