Restore netfx test configuration to serve as oracle
authorStephen Toub <stoub@microsoft.com>
Sun, 5 Jan 2020 20:20:45 +0000 (15:20 -0500)
committerStephen Toub <stoub@microsoft.com>
Thu, 9 Jan 2020 03:50:10 +0000 (22:50 -0500)
With all the changes being made in the regex implementation in this release, we want to make sure we don't regress, and a good way to help doing that is add a bunch of tests and ensure they pass on netfx as well, where appropriate.

src/libraries/System.Text.RegularExpressions/tests/Configurations.props
src/libraries/System.Text.RegularExpressions/tests/Regex.Cache.Tests.cs
src/libraries/System.Text.RegularExpressions/tests/Regex.Groups.Tests.cs
src/libraries/System.Text.RegularExpressions/tests/Regex.Match.Tests.cs
src/libraries/System.Text.RegularExpressions/tests/Regex.MultipleMatches.Tests.cs
src/libraries/System.Text.RegularExpressions/tests/RegexParserTests.cs

index b6e0d3c..3e0106d 100644 (file)
@@ -2,6 +2,7 @@
   <PropertyGroup>
     <BuildConfigurations>
       $(NetCoreAppCurrent);
+      $(NetFrameworkCurrent);
     </BuildConfigurations>
   </PropertyGroup>
 </Project>
\ No newline at end of file
index db10fe8..eee4af3 100644 (file)
@@ -10,6 +10,7 @@ using Xunit;
 
 namespace System.Text.RegularExpressions.Tests
 {
+    [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
     public class RegexCacheTests
     {
         [Theory]
index 5b3fe72..0a72e4a 100644 (file)
@@ -390,8 +390,11 @@ namespace System.Text.RegularExpressions.Tests
             yield return new object[] { null, @"(cat)(\cZ*)(dog)", "asdlkcat\u001adogiwod", RegexOptions.None, new string[] { "cat\u001adog", "cat", "\u001a", "dog" } };
             yield return new object[] { null, @"(cat)(\cz*)(dog)", "asdlkcat\u001adogiwod", RegexOptions.None, new string[] { "cat\u001adog", "cat", "\u001a", "dog" } };
 
-            yield return new object[] { null, @"(cat)(\c[*)(dog)", "asdlkcat\u001bdogiwod", RegexOptions.None, new string[] { "cat\u001bdog", "cat", "\u001b", "dog" } };
-            yield return new object[] { null, @"(cat)(\c[*)(dog)", "asdlkcat\u001Bdogiwod", RegexOptions.None, new string[] { "cat\u001Bdog", "cat", "\u001B", "dog" } };
+            if (!PlatformDetection.IsFullFramework) // missing fix for #26501
+            {
+                yield return new object[] { null, @"(cat)(\c[*)(dog)", "asdlkcat\u001bdogiwod", RegexOptions.None, new string[] { "cat\u001bdog", "cat", "\u001b", "dog" } };
+                yield return new object[] { null, @"(cat)(\c[*)(dog)", "asdlkcat\u001Bdogiwod", RegexOptions.None, new string[] { "cat\u001Bdog", "cat", "\u001B", "dog" } };
+            }
 
             // Atomic Zero-Width Assertions \A \Z \z \G \b \B
             //\A
index c2f51e0..37e64ef 100644 (file)
@@ -295,7 +295,10 @@ namespace System.Text.RegularExpressions.Tests
             yield return new object[] { @"[a-[a-f]]", "abcdefghijklmnopqrstuvwxyz", RegexOptions.None, 0, 26, false, string.Empty };
 
             // \c
-            yield return new object[] { @"(cat)(\c[*)(dog)", "asdlkcat\u00FFdogiwod", RegexOptions.None, 0, 15, false, string.Empty };
+            if (!PlatformDetection.IsFullFramework) // missing fix for #26501
+            {
+                yield return new object[] { @"(cat)(\c[*)(dog)", "asdlkcat\u00FFdogiwod", RegexOptions.None, 0, 15, false, string.Empty };
+            }
 
             // Surrogate pairs splitted up into UTF-16 code units.
             yield return new object[] { @"(\uD82F[\uDCA0-\uDCA3])", "\uD82F\uDCA2", RegexOptions.CultureInvariant, 0, 2, true, "\uD82F\uDCA2" };
@@ -808,6 +811,7 @@ namespace System.Text.RegularExpressions.Tests
         }
 
         [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))] // times out on ARM
+        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, "Full framework needs fix for #26484")]
         [SkipOnCoreClr("Long running tests: https://github.com/dotnet/coreclr/issues/18912", RuntimeStressTestModes.JitMinOpts)]
         public void Match_ExcessPrefix()
         {
index 321ffe5..6ac0975 100644 (file)
@@ -141,18 +141,21 @@ namespace System.Text.RegularExpressions.Tests
                 }
             };
 
-            yield return new object[]
+            if (!PlatformDetection.IsFullFramework) // missing fix in https://github.com/dotnet/runtime/pull/993
             {
-                "[^]", "every", RegexOptions.ECMAScript,
-                new CaptureData[]
+                yield return new object[]
                 {
-                    new CaptureData("e", 0, 1),
-                    new CaptureData("v", 1, 1),
-                    new CaptureData("e", 2, 1),
-                    new CaptureData("r", 3, 1),
-                    new CaptureData("y", 4, 1),
-                }
-            };
+                    "[^]", "every", RegexOptions.ECMAScript,
+                    new CaptureData[]
+                    {
+                        new CaptureData("e", 0, 1),
+                        new CaptureData("v", 1, 1),
+                        new CaptureData("e", 2, 1),
+                        new CaptureData("r", 3, 1),
+                        new CaptureData("y", 4, 1),
+                    }
+                };
+            }
         }
 
         [Theory]
index 61003d2..c8c7a5e 100644 (file)
@@ -15,8 +15,11 @@ namespace System.Text.RegularExpressions.Tests
 
         static RegexParserTests()
         {
-            s_parseExceptionType = typeof(Regex).Assembly.GetType("System.Text.RegularExpressions.RegexParseException", true);
-            s_parseErrorField = s_parseExceptionType.GetField("_error", BindingFlags.NonPublic | BindingFlags.Instance);
+            if (!PlatformDetection.IsFullFramework)
+            {
+                s_parseExceptionType = typeof(Regex).Assembly.GetType("System.Text.RegularExpressions.RegexParseException", true);
+                s_parseErrorField = s_parseExceptionType.GetField("_error", BindingFlags.NonPublic | BindingFlags.Instance);
+            }
         }
 
         [Theory]
@@ -800,6 +803,7 @@ namespace System.Text.RegularExpressions.Tests
         [InlineData("a{0,2147483648}", RegexOptions.None, RegexParseError.CaptureGroupOutOfRange)]
         // Surrogate pair which is parsed as [char,char-char,char] as we operate on UTF-16 code units.
         [InlineData("[\uD82F\uDCA0-\uD82F\uDCA3]", RegexOptions.IgnoreCase, RegexParseError.ReversedCharRange)]
+        [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
         public void Parse_NotNetFramework(string pattern, RegexOptions options, object error)
         {
             Parse(pattern, options, error);
@@ -858,11 +862,19 @@ namespace System.Text.RegularExpressions.Tests
         /// <param name="action">The action to invoke.</param>
         private static void Throws(RegexParseError error, Action action)
         {
+            // If no specific error is supplied, or we are running on full framework where RegexParseException
+            // we expect an ArgumentException.
+            if (PlatformDetection.IsFullFramework)
+            {
+                Assert.ThrowsAny<ArgumentException>(action);
+                return;
+            }
+
             try
             {
                 action();
             }
-            catch (Exception e)
+            catch (ArgumentException e)
             {
                 // We use reflection to check if the exception is an internal RegexParseException
                 // and extract its error property and compare with the given one.