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.
<PropertyGroup>
<BuildConfigurations>
$(NetCoreAppCurrent);
+ $(NetFrameworkCurrent);
</BuildConfigurations>
</PropertyGroup>
</Project>
\ No newline at end of file
namespace System.Text.RegularExpressions.Tests
{
+ [SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework)]
public class RegexCacheTests
{
[Theory]
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
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" };
}
[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()
{
}
};
- 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]
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]
[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);
/// <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.