Skip to content

test(result): cover Flatten's post-first-failure null check (code review) - #279

Merged
Chris-Wolfgang merged 1 commit into
vNextfrom
tier2/review-flatten-null-coverage
Jul 17, 2026
Merged

test(result): cover Flatten's post-first-failure null check (code review)#279
Chris-Wolfgang merged 1 commit into
vNextfrom
tier2/review-flatten-null-coverage

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Adds one targeted test for the only uncovered line the full-repo code review found in the src assembly.

Summary

Result.Flatten has 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 after firstFailureIndex is 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 — passes Result.Flatten(Failure, null!, Success) and asserts ArgumentException with index 1 in the message.

Coverage delta

  • Before: 99% line / 96.7% branch / 100% method on Wolfgang.TryPattern
  • After: 100% line / 96.6% branch / 100% method (0 uncovered lines)

The 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.

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>
Copilot AI review requested due to automatic review settings July 16, 2026 13:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants