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

Port -- WASM: enable System.Runtime.Tests to Preview8 #39478

Merged
merged 2 commits into from
Jul 17, 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
2 changes: 1 addition & 1 deletion eng/illink.targets
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
<ILLinkArgs Condition="'$(ILLinkSubstitutionsXml)' != ''">$(ILLinkArgs) --strip-substitutions false</ILLinkArgs>
<!-- don't remove the embedded link attributes xml resource since ILLink may run again on the assembly -->
<!-- and ignore the link attributes xml file during the library build, since we need the attributes preserved until the final app is linked -->
<ILLinkArgs Condition="'$(ILLinkLinkAttributesXml)' != ''">$(ILLinkArgs) --strip-link-attributes false --ignore-link-attributes true</ILLinkArgs>
<ILLinkArgs>$(ILLinkArgs) --strip-link-attributes false --ignore-link-attributes true</ILLinkArgs>
<!-- ignore unresolved references -->
<ILLinkArgs>$(ILLinkArgs) --skip-unresolved true</ILLinkArgs>
<!-- keep interface implementations -->
Expand Down
648 changes: 350 additions & 298 deletions src/libraries/Common/tests/Tests/System/StringTests.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/libraries/System.Runtime/tests/System/ActivatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ public void CreateInstance_PublicOnlyValueTypeWithPrivateDefaultConstructor_Thro
}

[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux | TestPlatforms.Browser, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[MemberData(nameof(TestingCreateInstanceFromObjectHandleData))]
public static void TestingCreateInstanceFromObjectHandle(string physicalFileName, string assemblyFile, string type, string returnedFullNameType, Type exceptionType)
{
Expand Down Expand Up @@ -717,7 +717,7 @@ public static void TestingCreateInstanceObjectHandle(string assemblyName, string
};

[Theory]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[ActiveIssue("https://github.com/dotnet/runtime/issues/34030", TestPlatforms.Linux | TestPlatforms.Browser, TargetFrameworkMonikers.Netcoreapp, TestRuntimes.Mono)]
[MemberData(nameof(TestingCreateInstanceFromObjectHandleFullSignatureData))]
public static void TestingCreateInstanceFromObjectHandleFullSignature(string physicalFileName, string assemblyFile, string type, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes, string returnedFullNameType)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace System.Tests
{
public static class ArgIteratorTests
{
[ActiveIssue("https://github.com/dotnet/runtime/issues/39343", TestPlatforms.Browser)]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsArgIteratorSupported))]
public static void ArgIterator_GetRemainingCount_GetNextArg()
{
Expand Down
40 changes: 28 additions & 12 deletions src/libraries/System.Runtime/tests/System/CharTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -942,16 +942,28 @@ private static IEnumerable<char> GetTestChars(params UnicodeCategory[] categorie
{
for (int i = 0; i < categories.Length; i++)
{
char[] latinSet = s_latinTestSet[(int)categories[i]];
UnicodeCategory category = categories[i];
char[] latinSet = s_latinTestSet[(int)category];
for (int j = 0; j < latinSet.Length; j++)
yield return latinSet[j];
if (ShouldTestCasingForChar(latinSet[j], category))
yield return latinSet[j];

char[] unicodeSet = s_unicodeTestSet[(int)categories[i]];
char[] unicodeSet = s_unicodeTestSet[(int)category];
for (int k = 0; k < unicodeSet.Length; k++)
yield return unicodeSet[k];
if (ShouldTestCasingForChar(unicodeSet[k], category))
yield return unicodeSet[k];
}
}

private static bool ShouldTestCasingForChar(char ch, UnicodeCategory category)
{
return PlatformDetection.IsNotInvariantGlobalization ||
(category != UnicodeCategory.UppercaseLetter &&
category != UnicodeCategory.LowercaseLetter) ||
ch >= 'a' && ch <= 'z' ||
ch >= 'A' && ch <= 'Z';
}

private static char[][] s_latinTestSet = new char[][]
{
new char[] {'\u0047','\u004c','\u0051','\u0056','\u00c0','\u00c5','\u00ca','\u00cf','\u00d4','\u00da'}, // UnicodeCategory.UppercaseLetter
Expand Down Expand Up @@ -1063,11 +1075,15 @@ private static IEnumerable<char> GetTestChars(params UnicodeCategory[] categorie
public static IEnumerable<object[]> UpperLowerCasing_TestData()
{
// lower upper Culture
yield return new object[] { 'a', 'A', "en-US" };
yield return new object[] { 'i', 'I', "en-US" };
yield return new object[] { '\u0131', 'I', "tr-TR" };
yield return new object[] { 'i', '\u0130', "tr-TR" };
yield return new object[] { '\u0660', '\u0660', "en-US" };
yield return new object[] { 'a', 'A', "en-US" };
yield return new object[] { 'i', 'I', "en-US" };

if (PlatformDetection.IsNotInvariantGlobalization)
{
yield return new object[] { '\u0131', 'I', "tr-TR" };
yield return new object[] { 'i', '\u0130', "tr-TR" };
yield return new object[] { '\u0660', '\u0660', "en-US" };
}
}

[Fact]
Expand All @@ -1076,7 +1092,7 @@ public static void LatinRangeTest()
StringBuilder sb = new StringBuilder(256);
string latineString = sb.ToString();

for (int i=0; i < latineString.Length; i++)
for (int i = 0; i < latineString.Length; i++)
{
Assert.Equal(s_categoryForLatin1[i], char.GetUnicodeCategory(latineString[i]));
Assert.Equal(s_categoryForLatin1[i], char.GetUnicodeCategory(latineString, i));
Expand All @@ -1086,14 +1102,14 @@ public static void LatinRangeTest()
[Fact]
public static void NonLatinRangeTest()
{
for (int i=256; i <= 0xFFFF; i++)
for (int i = 256; i <= 0xFFFF; i++)
{
Assert.Equal(CharUnicodeInfo.GetUnicodeCategory((char)i), char.GetUnicodeCategory((char)i));
}

string nonLatinString = "\u0100\u0200\u0300\u0400\u0500\u0600\u0700\u0800\u0900\u0A00\u0B00\u0C00\u0D00\u0E00\u0F00" +
"\u1000\u2000\u3000\u4000\u5000\u6000\u7000\u8000\u9000\uA000\uB000\uC000\uD000\uE000\uF000";
for (int i=0; i < nonLatinString.Length; i++)
for (int i = 0; i < nonLatinString.Length; i++)
{
Assert.Equal(CharUnicodeInfo.GetUnicodeCategory(nonLatinString[i]), char.GetUnicodeCategory(nonLatinString, i));
}
Expand Down
13 changes: 8 additions & 5 deletions src/libraries/System.Runtime/tests/System/DateTimeOffsetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1238,15 +1238,18 @@ public static IEnumerable<object[]> ToString_MatchesExpected_MemberData()
yield return new object[] { new DateTimeOffset(1617181518122280616, TimeSpan.FromSeconds(26280)), "O", null, "5125-08-24T20:50:12.2280616+07:18" };

// Year patterns

var enUS = new CultureInfo("en-US");
var thTH = new CultureInfo("th-TH");
yield return new object[] { new DateTimeOffset(new DateTime(1234, 5, 6)), "yy", enUS, "34" };
yield return new object[] { DateTimeOffset.MaxValue, "yy", thTH, "42" };
if (PlatformDetection.IsNotInvariantGlobalization)
yield return new object[] { DateTimeOffset.MaxValue, "yy", thTH, "42" };

for (int i = 3; i < 20; i++)
{
yield return new object[] { new DateTimeOffset(new DateTime(1234, 5, 6)), new string('y', i), enUS, 1234.ToString("D" + i) };
yield return new object[] { DateTimeOffset.MaxValue, new string('y', i), thTH, 10542.ToString("D" + i) };

if (PlatformDetection.IsNotInvariantGlobalization)
yield return new object[] { DateTimeOffset.MaxValue, new string('y', i), thTH, 10542.ToString("D" + i) };
}
}

Expand All @@ -1268,7 +1271,7 @@ public static IEnumerable<object[]> ToString_WithCulture_MatchesExpected_MemberD
yield return new object[] { new DateTimeOffset(636572516255571994, TimeSpan.FromHours(-5)), "Y", new CultureInfo("da-DK"), "marts 2018" };
}

[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
[MemberData(nameof(ToString_WithCulture_MatchesExpected_MemberData))]
public static void ToString_WithCulture_MatchesExpected(DateTimeOffset dateTimeOffset, string format, CultureInfo culture, string expected)
{
Expand Down Expand Up @@ -1349,7 +1352,7 @@ public static void TryFormat_ToString_EqualResults()
Assert.Equal(0, actual[actual.Length - 1]);
}

[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
[MemberData(nameof(ToString_MatchesExpected_MemberData))]
public static void TryFormat_MatchesExpected(DateTimeOffset dateTimeOffset, string format, IFormatProvider provider, string expected)
{
Expand Down
58 changes: 38 additions & 20 deletions src/libraries/System.Runtime/tests/System/DateTimeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1711,13 +1711,16 @@ public static IEnumerable<object[]> Parse_ValidInput_Succeeds_MemberData()
yield return new object[] { "2 2 2Z", CultureInfo.InvariantCulture, TimeZoneInfo.ConvertTimeFromUtc(new DateTime(2002, 2, 2, 0, 0, 0, DateTimeKind.Utc), TimeZoneInfo.Local) };
yield return new object[] { "#10/10/2095#\0", CultureInfo.InvariantCulture, new DateTime(2095, 10, 10, 0, 0, 0) };

DateTime today = DateTime.Today;
var hebrewCulture = new CultureInfo("he-IL");
hebrewCulture.DateTimeFormat.Calendar = new HebrewCalendar();
yield return new object[] { today.ToString(hebrewCulture), hebrewCulture, today };
if (PlatformDetection.IsNotInvariantGlobalization)
{
DateTime today = DateTime.Today;
var hebrewCulture = new CultureInfo("he-IL");
hebrewCulture.DateTimeFormat.Calendar = new HebrewCalendar();
yield return new object[] { today.ToString(hebrewCulture), hebrewCulture, today };

var mongolianCulture = new CultureInfo("mn-MN");
yield return new object[] { today.ToString(mongolianCulture), mongolianCulture, today };
var mongolianCulture = new CultureInfo("mn-MN");
yield return new object[] { today.ToString(mongolianCulture), mongolianCulture, today };
}
}

[Theory]
Expand Down Expand Up @@ -1832,12 +1835,15 @@ public static IEnumerable<object[]> ParseExact_ValidInput_Succeeds_MemberData()
yield return new object[] { " 9 / 8 / 2017 10 : 11 : 12 AM", "M/d/yyyy HH':'mm':'ss tt\' \'", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, new DateTime(2017, 9, 8, 10, 11, 12) };
yield return new object[] { " 9 / 8 / 2017 10 : 11 : 12 AM", "M/d/yyyy HH':'mm':'ss tt\' \'", CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces, new DateTime(2017, 9, 8, 10, 11, 12) };

var hebrewCulture = new CultureInfo("he-IL");
hebrewCulture.DateTimeFormat.Calendar = new HebrewCalendar();
DateTime today = DateTime.Today;
foreach (string pattern in hebrewCulture.DateTimeFormat.GetAllDateTimePatterns())
if (PlatformDetection.IsNotInvariantGlobalization)
{
yield return new object[] { today.ToString(pattern, hebrewCulture), pattern, hebrewCulture, DateTimeStyles.None, null };
var hebrewCulture = new CultureInfo("he-IL");
hebrewCulture.DateTimeFormat.Calendar = new HebrewCalendar();
DateTime today = DateTime.Today;
foreach (string pattern in hebrewCulture.DateTimeFormat.GetAllDateTimePatterns())
{
yield return new object[] { today.ToString(pattern, hebrewCulture), pattern, hebrewCulture, DateTimeStyles.None, null };
}
}
}

Expand Down Expand Up @@ -2004,15 +2010,27 @@ public static IEnumerable<object[]> ToString_MatchesExpected_MemberData()
yield return new object[] { new DateTime(221550163152616218, DateTimeKind.Utc), "r", null, "Sun, 25 Jan 0703 19:11:55 GMT" };

// Year patterns

var enUS = new CultureInfo("en-US");
var thTH = new CultureInfo("th-TH");
yield return new object[] { new DateTime(1234, 5, 6), "yy", enUS, "34" };
yield return new object[] { DateTime.MaxValue, "yy", thTH, "42" };
for (int i = 3; i < 20; i++)
if (PlatformDetection.IsNotInvariantGlobalization)
{
var enUS = new CultureInfo("en-US");
var thTH = new CultureInfo("th-TH");
yield return new object[] { new DateTime(1234, 5, 6), "yy", enUS, "34" };
yield return new object[] { DateTime.MaxValue, "yy", thTH, "42" };
for (int i = 3; i < 20; i++)
{
yield return new object[] { new DateTime(1234, 5, 6), new string('y', i), enUS, 1234.ToString("D" + i) };
yield return new object[] { DateTime.MaxValue, new string('y', i), thTH, 10542.ToString("D" + i) };
}
}
else
{
yield return new object[] { new DateTime(1234, 5, 6), new string('y', i), enUS, 1234.ToString("D" + i) };
yield return new object[] { DateTime.MaxValue, new string('y', i), thTH, 10542.ToString("D" + i) };
var invariant = new CultureInfo("");
yield return new object[] { new DateTime(1234, 5, 6), "yy", invariant, "34" };

for (int i = 3; i < 20; i++)
{
yield return new object[] { new DateTime(1234, 5, 6), new string('y', i), invariant, 1234.ToString("D" + i) };
}
}
}

Expand Down Expand Up @@ -2299,7 +2317,7 @@ public static void TryFormat_MatchesToString(string format)
Assert.Equal(0, dest[dest.Length - 1]);
}

[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
[MemberData(nameof(ToString_MatchesExpected_MemberData))]
public static void TryFormat_MatchesExpected(DateTime dateTime, string format, IFormatProvider provider, string expected)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public static unsafe void TestRefReturnOfPointer()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/39380", TestPlatforms.Browser)]
public static unsafe void TestNullRefReturnOfPointer()
{
TestClassIntPointer tc = new TestClassIntPointer(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public static void SetCurrentStackTrace_Invalid_Throws()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/39341", TestPlatforms.Browser)]
public static void SetCurrentStackTrace_IncludedInExceptionStackTrace()
{
Exception e;
Expand Down
Loading