From bbb1534fd90ab4722b6dbaea251b2716c1d9dc68 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Mon, 28 Jul 2025 17:27:52 -0400 Subject: [PATCH] Add a regex test for a loop followed by a positive lookahead Locally I made a change (allowing loops to be made atomic based on a positive lookahead after them) that should have failed tests but didn't. This adds a test that would have caught the issue. --- .../tests/FunctionalTests/Regex.Match.Tests.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs index d4ecf2a77fcfa6..2183e68a91ea2e 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs @@ -97,6 +97,9 @@ public static IEnumerable Match_MemberData() yield return (@"(?=(abc))+\1", "abc", RegexOptions.None, 0, 3, true, "abc"); yield return (@"(?=(abc))*\1", "abc", RegexOptions.None, 0, 3, true, "abc"); + // Zero-width positive lookahead assertion + yield return (@"a*(?=b)\bb", "ab", RegexOptions.None, 0, 2, true, "ab"); + // Zero-width positive lookbehind assertion yield return (@"(\w){6}(?<=XXX)def", "abcXXXdef", RegexOptions.None, 0, 9, true, "abcXXXdef"); yield return (@"(?<=c)def", "123abcdef", RegexOptions.None, 0, 9, true, "def");