Add missing tests for resumeAt=2 path in regex expression conditional#126657
Add missing tests for resumeAt=2 path in regex expression conditional#126657danmoseley merged 5 commits intomainfrom
Conversation
…tions-workflow Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com>
…n loop) The Code Review agent identified that existing tests cover resumeAt=0 and resumeAt=1 paths but miss the resumeAt=2 pass-through path (expression conditional with only a yes-branch, no no-branch, inside a loop). Add three test cases: - Yes-only conditional where condition always fails (exercises pass-through) - Yes-only conditional with prefix capture feeding the condition (even input) - Yes-only conditional with prefix capture feeding the condition (odd input) Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/6ba8b4ff-5be3-4c6a-aa69-f84b202c2d67 Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com>
|
I requested this accidentally - clicked on wrong menu option on the other PR -- but since apparently these are missing, let's merge this I guess. |
There was a problem hiding this comment.
Pull request overview
Adds missing functional coverage for the resumeAt=2 “pass-through” path when compiling/executing expression conditionals with only a yes-branch inside a loop, as identified by the Code Review workflow.
Changes:
- Adds a new test case where a yes-only expression conditional inside a
+loop produces empty matches (pass-through path). - Adds two additional test cases for a yes-only conditional driven by a prefix capture, validating even/odd input behavior (full vs partial match).
Show a summary per file
| File | Description |
|---|---|
src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.MultipleMatches.Tests.cs |
Extends Matches_TestData() with 3 new cases targeting yes-only expression-conditionals in loops, including the previously untested pass-through path. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
|
Removed Stephen - habit - adding @jkotas for hopefully a easy signoff. |
|
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions |
|
The failures look related: |
|
@copilot investigate failures. We expect the same results in .NET Framework |
The first test case produces 4 empty matches on .NET Core but 3 on .NET Framework due to different empty-match-at-end-of-string semantics. Move it inside the existing #if !NETFRAMEWORK block. The two remaining tests (with non-empty matches) stay on both platforms and are the ones that actually exercise the isInLoop fix for resumeAt=2. Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/63d10d88-afd5-4662-a324-539b9a293f4e Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com>
Head branch was pushed to by a user without write access
The first test case The two remaining tests (with non-empty matches) stay on both platforms — and they're the ones that actually exercise the |
|
Uh, we should not uncritically accept different results for netfx... |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds missing test coverage for the resumeAt=2 “pass-through” path in regex expression conditionals (specifically: yes-only conditionals inside loops), as flagged by the Code Review workflow on the prior fix PR.
Changes:
- Add two cross-target test cases for a yes-only expression conditional inside a loop, validating even/odd input behavior.
- Add one
#if !NETFRAMEWORKtest case that exercises the yes-only conditional “condition fails → pass-through” path that produces empty matches (excluded due to known .NET Framework empty-match semantic differences).
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.MultipleMatches.Tests.cs | Adds three Matches_TestData cases targeting the missing resumeAt=2 coverage scenario for expression conditionals inside loops. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
🤖 Copilot Code Review — PR #126657Note This review was generated by Copilot. Holistic AssessmentMotivation: This PR adds targeted test coverage for the Approach: Adding test cases to the existing Summary: ✅ LGTM. This is a clean, test-only change that fills a real coverage gap. The three test cases are correctly constructed, properly guarded, and the expected results are accurate. Detailed Findings✅ Correctness — Test patterns and expected results verifiedI traced each regex pattern against its input:
✅ Guard placement — Correct nesting
✅ Consistency — Follows existing patternsThe test data format ( ✅ Coverage alignment — Exercises the targeted fixThe parent PR #126561 added
|
Description
The Code Review workflow on PR #126561 identified that the new tests cover
resumeAt=0(yes-branch) andresumeAt=1(no-branch) paths but miss theresumeAt=2pass-through path — expression conditional with only a yes-branch (no no-branch) inside a loop.Adds 3 test cases to
Regex.MultipleMatches.Tests.cs:(?((?'-1'))(?'1'.)+)+(?!(?'-1'))with"abc"exercises the pass-through path producing empty matches at each position (guarded with#if !NETFRAMEWORKsince .NET Framework produces 3 empty matches vs 4 on .NET Core due to different empty-match-at-end-of-string semantics)((?'1'.)(?((?'-1'))(?'1'.)))+with"abcd"exercises the yes-branch-taken path inside a loop"abc"verifying partial match behaviorThe latter two test cases are the primary coverage for the
|| isInLoopfix, since their non-backtracking yes-branch meansisInLoopis the necessary trigger forresumeAt = 2(the old conditionpostYesDoneLabel != originalDoneLabelwould have been false). These run on both .NET Core and .NET Framework.All 32,100 existing tests continue to pass.