Add more regex tests (and fix one atomicity bug) (#33458)
authorStephen Toub <stoub@microsoft.com>
Wed, 11 Mar 2020 21:28:02 +0000 (17:28 -0400)
committerGitHub <noreply@github.com>
Wed, 11 Mar 2020 21:28:02 +0000 (17:28 -0400)
commit83016f3bf2b5c4331bec431ef19a72064552779d
treed398eeb3df876988ef217e6a830589453a4bee9e
parent2b27323e4aa61f540b8c6600f4add5b29860a0a3
Add more regex tests (and fix one atomicity bug) (#33458)

* Avoid automatically making Regex loops followed by a lookbehind atomic

We allow a positive lookahead to be used to determine whether a loop can be upgraded to be atomic, but we're currently missing the RTL check that distinguishes between positive lookaheads and positive lookbehinds, so we're currently erroneously making some loops followed by positive lookbehinds atomic when we shouldn't.  Fix that just by ensuring we only traverse Require nodes when they're lookahead rather than behind.

Also, just for additional safety, change a subsequent check to ensure that the two nodes being compared have identical options.  Today we're just checking for case-sensitivity, but it's more robust (and doesn't hurt) to just check all options.

* Add more tests to boost code coverage

Plus lookaround tests for min length computation
12 files changed:
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexNode.cs
src/libraries/System.Text.RegularExpressions/tests/GroupCollectionTests.cs
src/libraries/System.Text.RegularExpressions/tests/Regex.CompileToAssembly.Tests.cs
src/libraries/System.Text.RegularExpressions/tests/Regex.Ctor.Tests.cs
src/libraries/System.Text.RegularExpressions/tests/Regex.EscapeUnescape.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.Replace.Tests.cs
src/libraries/System.Text.RegularExpressions/tests/Regex.Split.Tests.cs
src/libraries/System.Text.RegularExpressions/tests/RegexCharacterSetTests.cs
src/libraries/System.Text.RegularExpressions/tests/RegexParserTests.cs
src/libraries/System.Text.RegularExpressions/tests/RegexReductionTests.cs