Skip to content

Commit 028dc4f

Browse files
authored
[TestOnly] port test fixes (#89065)
1 parent 216f6ee commit 028dc4f

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCtor.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ public static IEnumerable<object[]> Ctor_String_TestData()
254254
yield return new object[] { "pa-IN", new [] { "pa-IN" }, true };
255255
yield return new object[] { "pl", new [] { "pl" } };
256256
yield return new object[] { "pl-PL", new [] { "pl-PL" } };
257-
yield return new object[] { "prs", new [] { "prs" }, true };
258-
yield return new object[] { "prs-AF", new [] { "prs-AF" }, true };
257+
yield return new object[] { "prs", new [] { "prs", "fa" }, true };
258+
yield return new object[] { "prs-AF", new [] { "prs-AF", "fa-AF" }, true};
259259
yield return new object[] { "ps", new [] { "ps" }, true };
260260
yield return new object[] { "ps-AF", new [] { "ps-AF" }, true };
261261
yield return new object[] { "pt", new [] { "pt" } };
@@ -460,7 +460,7 @@ public void TestCreationWithMangledSortName(string cultureName, string expectedC
460460
Assert.Equal(expectedSortName, ci.CompareInfo.Name);
461461
}
462462

463-
private static bool SupportRemoteExecutionWithIcu => RemoteExecutor.IsSupported && PlatformDetection.IsIcuGlobalization;
463+
private static bool SupportRemoteExecutionWithIcu => RemoteExecutor.IsSupported && PlatformDetection.IsIcuGlobalization && PlatformDetection.IsNotWindowsServerCore;
464464

465465
[InlineData("xx-u-XX", "xx-u-xx")]
466466
[InlineData("xx-u-XX-u-yy", "xx-u-xx-u-yy")]

src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoCurrencyGroupSizes.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ public class NumberFormatInfoCurrencyGroupSizes
1010
{
1111
public static IEnumerable<object[]> CurrencyGroupSizes_TestData()
1212
{
13-
yield return new object[] { NumberFormatInfo.InvariantInfo, new int[] { 3 } };
14-
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, new int[] { 3 } };
13+
yield return new object[] { NumberFormatInfo.InvariantInfo, new int[] { 3 }, null };
14+
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, new int[] { 3 }, null };
1515

1616
if (PlatformDetection.IsNotUsingLimitedCultures && !PlatformDetection.IsUbuntu && !PlatformDetection.IsWindows7 && !PlatformDetection.IsWindows8x && !PlatformDetection.IsFedora)
1717
{
18-
yield return new object[] { CultureInfo.GetCultureInfo("ur-IN").NumberFormat, new int[] { 3, 2 } };
18+
yield return new object[] { CultureInfo.GetCultureInfo("ur-IN").NumberFormat, new int[] { 3, 2 }, new int[] { 3 }};
1919
}
2020
}
2121

2222
[Theory]
2323
[MemberData(nameof(CurrencyGroupSizes_TestData))]
24-
public void CurrencyGroupSizes_Get_ReturnsExpected(NumberFormatInfo format, int[] expected)
24+
public void CurrencyGroupSizes_Get_ReturnsExpected(NumberFormatInfo format, int[] expected, int [] expectedAlternative)
2525
{
26-
Assert.Equal(expected, format.CurrencyGroupSizes);
26+
Assert.True(format.CurrencyGroupSizes.AsSpan().SequenceEqual(expected.AsSpan()) || format.CurrencyGroupSizes.AsSpan().SequenceEqual(expectedAlternative.AsSpan()),
27+
$"Expected {string.Join(", ", expected)} or {string.Join(", ", expectedAlternative ?? Array.Empty<int>())}, got {string.Join(", ", format.CurrencyGroupSizes)}");
2728
}
2829

2930
[Theory]

src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoTests.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@ public static IEnumerable<object[]> DigitSubstitution_TestData()
5454
yield return new object[] { "nqo-GN" , DigitShapes.NativeNational };
5555
yield return new object[] { "pa-Arab" , DigitShapes.NativeNational };
5656
yield return new object[] { "pa-Arab-PK", DigitShapes.NativeNational };
57-
yield return new object[] { "prs" , DigitShapes.NativeNational };
58-
yield return new object[] { "prs-AF" , DigitShapes.NativeNational };
5957
yield return new object[] { "ps" , DigitShapes.NativeNational };
6058
yield return new object[] { "ps-AF" , DigitShapes.NativeNational };
6159
yield return new object[] { "sd" , DigitShapes.NativeNational };
@@ -115,6 +113,24 @@ public void DigitSubstitutionListTest(string cultureName, DigitShapes shape)
115113
}
116114
}
117115

116+
[Theory]
117+
[InlineData("prs")]
118+
[InlineData("prs-AF")]
119+
public void PrsNativeDigitsTest(string cultureName)
120+
{
121+
try
122+
{
123+
CultureInfo ci = CultureInfo.GetCultureInfo(cultureName);
124+
125+
// Some OS's set the DigitSubstitution to Context for the culture "prs" and "prs-AF". Majority of Os's set it to NativeNational.
126+
Assert.True(ci.NumberFormat.DigitSubstitution == DigitShapes.Context || ci.NumberFormat.DigitSubstitution == DigitShapes.NativeNational);
127+
}
128+
catch (CultureNotFoundException)
129+
{
130+
// ignore the cultures that we cannot create as it is not supported on the platforms
131+
}
132+
}
133+
118134
public static IEnumerable<object[]> NativeDigitTestData()
119135
{
120136
yield return new object[] { "ccp-Cakm-BD", new string[] { "\U0001E950", "\U0001E951", "\U0001E952", "\U0001E953", "\U0001E954", "\U0001E955", "\U0001E956", "\U0001E957", "\U0001E958", "\U0001E959" }};

0 commit comments

Comments
 (0)