test(result): cover Flatten's post-first-failure null check (code review) - #279
Merged
Merged
Conversation
Adds `Flatten_when_null_appears_after_first_failure_throws_ArgumentException` targeting the sole uncovered line the code review found in `src/Wolfgang.TryPattern/Result.cs:172` — the null-element check inside `Flatten`'s tail loop (after `firstFailureIndex` is set). The pre-existing null-in-Flatten test only covered a null seen BEFORE the first failure (head loop, line 148). This one exercises the tail loop's parallel throw, verifying the "no element escapes null validation" invariant the source comment claims (Result.cs:139-142). Coverage on `Wolfgang.TryPattern` src: 99% → **100%** line, still 100% method. Branch coverage 96.6% (2 uncovered branches are compiler- generated async state-machine paths per CLAUDE.md guidance). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5 tasks
This was referenced Jul 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds one targeted test for the only uncovered line the full-repo code review found in the src assembly.
Summary
Result.Flattenhas two null-checks — one in the head loop (line 148, covered by an existing test) and one in the tail loop (line 172, previously uncovered). The tail-loop check runs afterfirstFailureIndexis set, so it only fires when a null appears AFTER the first failure. The pre-existing test only exercised nulls BEFORE the first failure.Added
Flatten_when_null_appears_after_first_failure_throws_ArgumentException— passesResult.Flatten(Failure, null!, Success)and assertsArgumentExceptionwithindex 1in the message.Coverage delta
Wolfgang.TryPatternThe remaining 2 uncovered branches are compiler-generated async state-machine paths per CLAUDE.md guidance ("compiler-generated async state machine branches are expected gaps — don't chase them").
Stacked-PR base
Base =
vNext.Local run
dotnet test -c Release -f net10.0 --filter Flatten_when_null_appears_after_first_failure→ 1/1 pass.