Skip to content

Commit 1695689

Browse files
Copilotstephentoub
andcommitted
Move test cases to Regex.Match.Tests.cs as requested
Removed dedicated [Fact] test from RegexGeneratorParserTests.cs and added test cases to Regex.Match.Tests.cs. The cases are already inside the guard for non-backtracking engine (line 87), so they will be tested on all backtracking engines including the source generator. Co-authored-by: stephentoub <[email protected]>
1 parent fab31e0 commit 1695689

File tree

2 files changed

+4
-25
lines changed

2 files changed

+4
-25
lines changed

src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ public static IEnumerable<object[]> Match_MemberData()
182182
yield return (@"(?<=(abc)+?)", "123abc", RegexOptions.None, 0, 6, true, "");
183183
yield return (@"(?<=(abc)+?)", "123ab", RegexOptions.None, 0, 5, false, "");
184184
yield return (@"(?<=(abc)+?123)", "abcabc123", RegexOptions.None, 0, 9, true, "");
185+
// Regression test for https://github.com/dotnet/runtime/issues/120882
186+
// Lazy loops inside lookbehinds should generate valid code
187+
yield return (@"(?<=(abc)+?123)a", "abcabc123a", RegexOptions.None, 0, 10, true, "a");
188+
yield return (@"(?<=(abc)+?)a", "abca", RegexOptions.None, 0, 4, true, "a");
185189
yield return (@"a+(?!c)(?<=y)", "yaab", RegexOptions.None, 0, 4, false, "");
186190
yield return (@"(?<=a{2,4})b+", "aaabbb", RegexOptions.None, 0, 6, true, "bbb");
187191
yield return (@"(?<=a+)b+?", "aaabbb", RegexOptions.None, 0, 6, true, "b");

src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/RegexGeneratorParserTests.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,30 +1233,5 @@ partial class C
12331233
return handle.Process.StandardOutput.ReadToEnd();
12341234
}
12351235
}
1236-
1237-
[Fact]
1238-
public async Task LazyLoopInLookbehind_GeneratesValidCode()
1239-
{
1240-
// Regression test for https://github.com/dotnet/runtime/issues/XXXXX
1241-
// Lazy loops inside lookbehinds should generate valid code with accessible backtracking labels
1242-
Assert.Empty(await RegexGeneratorHelper.RunGenerator(@"
1243-
using System.Text.RegularExpressions;
1244-
1245-
partial class C
1246-
{
1247-
[GeneratedRegex(@""(?<=(abc)+?123)a"")]
1248-
public static partial Regex LazyLoopInLookbehind1();
1249-
1250-
[GeneratedRegex(@""xxx(?<=(abc)+?123)a"")]
1251-
public static partial Regex LazyLoopInLookbehind2();
1252-
1253-
[GeneratedRegex(@""(?<=(abc)+?123)"")]
1254-
public static partial Regex LazyLoopInLookbehind3();
1255-
1256-
[GeneratedRegex(@""(?<=(abc)+?)a"")]
1257-
public static partial Regex LazyLoopInLookbehind4();
1258-
}
1259-
", compile: true));
1260-
}
12611236
}
12621237
}

0 commit comments

Comments
 (0)