Commit dc803e0
Add missing tests for resumeAt=2 path in regex expression conditional (#126657)
## Description
The Code Review workflow on PR #126561 identified that the new tests
cover `resumeAt=0` (yes-branch) and `resumeAt=1` (no-branch) paths but
miss the `resumeAt=2` pass-through path — expression conditional with
only a yes-branch (no no-branch) inside a loop.
Adds 3 test cases to `Regex.MultipleMatches.Tests.cs`:
- **Yes-only conditional, condition always fails** —
`(?((?'-1'))(?'1'.)+)+(?!(?'-1'))` with `"abc"` exercises the
pass-through path producing empty matches at each position (guarded with
`#if !NETFRAMEWORK` since .NET Framework produces 3 empty matches vs 4
on .NET Core due to different empty-match-at-end-of-string semantics)
- **Yes-only conditional with prefix capture, even input** —
`((?'1'.)(?((?'-1'))(?'1'.)))+` with `"abcd"` exercises the
yes-branch-taken path inside a loop
- **Yes-only conditional with prefix capture, odd input** — same pattern
with `"abc"` verifying partial match behavior
The latter two test cases are the primary coverage for the `|| isInLoop`
fix, since their non-backtracking yes-branch means `isInLoop` is the
necessary trigger for `resumeAt = 2` (the old condition
`postYesDoneLabel != originalDoneLabel` would have been false). These
run on both .NET Core and .NET Framework.
All 32,100 existing tests continue to pass.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: danmoseley <6385855+danmoseley@users.noreply.github.com>
Co-authored-by: Dan Moseley <danmose@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 62b476b commit dc803e0
File tree
1 file changed
+28
-0
lines changed- src/libraries/System.Text.RegularExpressions/tests/FunctionalTests
1 file changed
+28
-0
lines changedLines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
582 | 582 | | |
583 | 583 | | |
584 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
585 | 601 | | |
586 | 602 | | |
587 | 603 | | |
| |||
611 | 627 | | |
612 | 628 | | |
613 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
614 | 642 | | |
615 | 643 | | |
616 | 644 | | |
| |||
0 commit comments