Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM enable System.Collections.NonGeneric.Tests #39020

Merged
merged 2 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ private static bool GetIsInvariantGlobalization()
public static Version ICUVersion => m_icuVersion.Value;

public static bool IsInvariantGlobalization => m_isInvariant.Value;
public static bool IsNotInvariantGlobalization => !IsInvariantGlobalization;
public static bool IsIcuGlobalization => ICUVersion > new Version(0,0,0,0);
public static bool IsNlsGlobalization => !IsIcuGlobalization;
public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !IsIcuGlobalization;

private static Version GetICUVersion()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,7 @@ public void Ctor_Empty_Compare(object a, object b, int expected)
[InlineData(null, null, 0)]
public void Ctor_CultureInfo_Compare(object a, object b, int expected)
{
var cultureNames = new string[]
{
"cs-CZ","da-DK","de-DE","el-GR","en-US",
"es-ES","fi-FI","fr-FR","hu-HU","it-IT",
"ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
"pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
"zh-CN","zh-HK","zh-TW"
};
var cultureNames = Helpers.TestCultureNames;

foreach (string cultureName in cultureNames)
{
Expand All @@ -74,14 +67,7 @@ public void Ctor_CultureInfo_Compare(object a, object b, int expected)
[Fact]
public void Ctor_CultureInfo_Compare_TurkishI()
{
var cultureNames = new string[]
{
"cs-CZ","da-DK","de-DE","el-GR","en-US",
"es-ES","fi-FI","fr-FR","hu-HU","it-IT",
"ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
"pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
"zh-CN","zh-HK","zh-TW"
};
var cultureNames = Helpers.TestCultureNames;

foreach (string cultureName in cultureNames)
{
Expand Down Expand Up @@ -132,14 +118,7 @@ public void Ctor_CultureInfo_NullCulture_ThrowsArgumentNullException()
[InlineData(null, null, 0)]
public void DefaultInvariant_Compare(object a, object b, int expected)
{
var cultureNames = new string[]
{
"cs-CZ","da-DK","de-DE","el-GR","en-US",
"es-ES","fi-FI","fr-FR","hu-HU","it-IT",
"ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
"pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
"zh-CN","zh-HK","zh-TW"
};
var cultureNames = Helpers.TestCultureNames;

foreach (string cultureName in cultureNames)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,7 @@ public void Ctor_Empty_GetHashCodeCompare(object a, object b, bool expected)
[InlineData(5, 10, false)]
public void Ctor_Empty_ChangeCurrentCulture_GetHashCodeCompare(object a, object b, bool expected)
{
var cultureNames = new string[]
{
"cs-CZ","da-DK","de-DE","el-GR","en-US",
"es-ES","fi-FI","fr-FR","hu-HU","it-IT",
"ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
"pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
"zh-CN","zh-HK","zh-TW"
};
var cultureNames = Helpers.TestCultureNames;

foreach (string cultureName in cultureNames)
{
Expand Down Expand Up @@ -80,14 +73,7 @@ public void Ctor_Empty_ChangeCurrentCulture_GetHashCodeCompare(object a, object
[InlineData(5, 10, false)]
public void Ctor_CultureInfo_ChangeCurrentCulture_GetHashCodeCompare(object a, object b, bool expected)
{
var cultureNames = new string[]
{
"cs-CZ","da-DK","de-DE","el-GR","en-US",
"es-ES","fi-FI","fr-FR","hu-HU","it-IT",
"ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
"pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
"zh-CN","zh-HK","zh-TW"
};
var cultureNames = Helpers.TestCultureNames;

foreach (string cultureName in cultureNames)
{
Expand All @@ -111,14 +97,7 @@ public void Ctor_CultureInfo_ChangeCurrentCulture_GetHashCodeCompare(object a, o
[Fact]
public void Ctor_CultureInfo_GetHashCodeCompare_TurkishI()
{
var cultureNames = new string[]
{
"cs-CZ","da-DK","de-DE","el-GR","en-US",
"es-ES","fi-FI","fr-FR","hu-HU","it-IT",
"ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
"pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
"zh-CN","zh-HK","zh-TW"
};
var cultureNames = Helpers.TestCultureNames;

foreach (string cultureName in cultureNames)
{
Expand Down Expand Up @@ -170,7 +149,7 @@ public void Default_GetHashCodeCompare(object a, object b, bool expected)
CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode(a) == CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode(b));
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
public void Default_Compare_TurkishI()
{
// Turkish has lower-case and upper-case version of the dotted "i", so the upper case of "i" (U+0069) isn't "I" (U+0049)
Expand Down
35 changes: 15 additions & 20 deletions src/libraries/System.Collections.NonGeneric/tests/ComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,7 @@ public void Ctor_CultureInfo_NullCulture_ThrowsArgumentNullException()
[Fact]
public void DefaultInvariant_Compare()
{
var cultureNames = new string[]
{
"cs-CZ","da-DK","de-DE","el-GR","en-US",
"es-ES","fi-FI","fr-FR","hu-HU","it-IT",
"ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
"pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
"zh-CN","zh-HK","zh-TW"
};
var cultureNames = Helpers.TestCultureNames;

var string1 = new string[] { "Apple", "abc", };
var string2 = new string[] { "\u00C6ble", "ABC" };
Expand All @@ -67,8 +60,9 @@ public void DefaultInvariant_Compare()
using (new ThreadCultureChange(culture, culture))
{
Comparer comp = Comparer.DefaultInvariant;
Assert.Equal(1, comp.Compare(string1[0], string2[0]));
Assert.Equal(-1, comp.Compare(string1[1], string2[1]));
/* Comparing in invariant mode compars firstChar - secondChar (A(65) - \u00C6(198) */
Assert.Equal(PlatformDetection.IsInvariantGlobalization ? -1 : 1, Math.Sign(comp.Compare(string1[0], string2[0])));
Assert.Equal(PlatformDetection.IsInvariantGlobalization ? 1 : -1, Math.Sign(comp.Compare(string1[1], string2[1])));
}
}
}
Expand All @@ -86,6 +80,17 @@ public void DefaultInvariant_Compare_Invalid()

public static IEnumerable<object[]> CompareTestData()
{
yield return new object[] { "hello", "hello", 0 };
yield return new object[] { "HELLO", "HELLO", 0 };
yield return new object[] { "hello", "HELLO", PlatformDetection.IsInvariantGlobalization ? 1 : -1 };
yield return new object[] { "hello", "goodbye", 1 };
yield return new object[] { 1, 2, -1 };
yield return new object[] { 2, 1, 1 };
yield return new object[] { 1, 1, 0 };
yield return new object[] { 1, null, 1 };
yield return new object[] { null, 1, -1 };
yield return new object[] { null, null, 0 };

yield return new object[] { new Foo(5), new Bar(5), 0 };
yield return new object[] { new Bar(5), new Foo(5), 0 };

Expand All @@ -94,16 +99,6 @@ public static IEnumerable<object[]> CompareTestData()
}

[Theory]
[InlineData("hello", "hello", 0)]
[InlineData("HELLO", "HELLO", 0)]
[InlineData("hello", "HELLO", -1)]
[InlineData("hello", "goodbye", 1)]
[InlineData(1, 2, -1)]
[InlineData(2, 1, 1)]
[InlineData(1, 1, 0)]
[InlineData(1, null, 1)]
[InlineData(null, 1, -1)]
[InlineData(null, null, 0)]
[MemberData(nameof(CompareTestData))]
public void Default_Compare(object a, object b, int expected)
{
Expand Down
12 changes: 12 additions & 0 deletions src/libraries/System.Collections.NonGeneric/tests/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ namespace System.Collections.Tests
{
internal static class Helpers
{
public static string[] TestCultureNames =>
PlatformDetection.IsInvariantGlobalization ?
new string[] { "" } :
new string[]
{
"cs-CZ","da-DK","de-DE","el-GR","en-US",
"es-ES","fi-FI","fr-FR","hu-HU","it-IT",
"ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
"pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
"zh-CN","zh-HK","zh-TW"
};

public static void PerformActionOnAllHashtableWrappers(Hashtable hashtable, Action<Hashtable> action)
{
// Synchronized returns a slightly different version of Hashtable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1339,14 +1339,7 @@ public void Item_Get_DifferentCulture()

try
{
var cultureNames = new string[]
{
"cs-CZ","da-DK","de-DE","el-GR","en-US",
"es-ES","fi-FI","fr-FR","hu-HU","it-IT",
"ja-JP","ko-KR","nb-NO","nl-NL","pl-PL",
"pt-BR","pt-PT","ru-RU","sv-SE","tr-TR",
"zh-CN","zh-HK","zh-TW"
};
var cultureNames = Helpers.TestCultureNames;

var installedCultures = new CultureInfo[cultureNames.Length];
var cultureDisplayNames = new string[installedCultures.Length];
Expand Down
1 change: 0 additions & 1 deletion src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<!-- Builds currently do not pass -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)Microsoft.VisualBasic.Core\tests\Microsoft.VisualBasic.Core.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.CodeDom\tests\System.CodeDom.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Collections.NonGeneric\tests\System.Collections.NonGeneric.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.ComponentModel.Annotations\tests\System.ComponentModel.Annotations.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.ComponentModel.Primitives\tests\System.ComponentModel.Primitives.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.ComponentModel.TypeConverter\tests\System.ComponentModel.TypeConverter.Tests.csproj" />
Expand Down