Skip to content

test(coverage): cover remaining reachable v7 branches#172

Merged
mellonis merged 1 commit into
v7from
chore/coverage-bump-v7-2
May 20, 2026
Merged

test(coverage): cover remaining reachable v7 branches#172
mellonis merged 1 commit into
v7from
chore/coverage-bump-v7-2

Conversation

@mellonis

Copy link
Copy Markdown
Owner

Summary

Follow-up to #171 β€” three more tests for v7 lines that #171's parser-error tests didn't reach:

  1. State.toGraph unbound-Reference catch in WRAPPER context (State.ts:463-464). There are two try/catch blocks for unbound Reference.ref in toGraph β€” one in the non-wrapper branch (already tested) and one in the wrapper-context branch (lines 463-464). The new test wraps the unbound-Ref bare via withOverriddenHaltState(...) to exercise the second branch.
  2. parseWriteSymbolLabel fallback return (graph.ts:209) β€” defensive return-as-is for unrecognized labels. Symmetric with the parsePatternString fallback that test(graphFormats): cover fromMermaid parser error pathsΒ #171 added.
  3. parsePatternString blank-marker ?? cell fallback (graph.ts:164) β€” defensive return when alphabets[tapeIx] is missing.

Why

#171 narrowed the Coveralls drop on PR #167 (v7 β†’ master) from -0.5% to less, but didn't fully clear it (Coveralls reported Coverage decreased (-0.5%) to 97.805%). This PR adds the remaining reasonably-reachable branches.

Coverage delta

Metric Pre-#171 After #171 After this PR Total Ξ”
Statements 98.29% 98.72% 99.14% +0.85
Branches 95.35% 96.13% 96.71% +1.36
Lines 98.32% β€” 99.21% +0.89
State.ts stmts 99.11% 99.11% 100% +0.89
graph.ts stmts 96.96% 100% 100% +3.04

Master's Coveralls baseline was ~98.305% lines; v7 is now at 99.21% β€” should land above master and clear the red.

What's NOT covered (intentional)

Two genuinely defensive branches not worth synthetic tests:

  • graphFormats.ts:344 β€” throw "malformed bracketed list" inside a stripBrackets closure that's only called with slices the parser itself constructs from regex-matched […] blocks. Not reachable via the public fromMermaid API.
  • introspection.ts:121 β€” if (node) guard in cycle detection for a node that's in the color map but not in graph.nodes. Can't happen with toGraph-produced graphs.

Test plan

Three more tests for the v7 lines #171 didn't reach:

- `State.toGraph` unbound-Reference catch in WRAPPER context
  (State.ts:463-464) β€” the existing test covered the non-wrapper
  branch; this one wraps the unbound-Ref state via
  `withOverriddenHaltState(...)` to hit the other try/catch
- `parseWriteSymbolLabel` fallback return (graph.ts:209) β€” defensive
  return-as-is for unrecognized labels
- `parsePatternString` blank-marker `?? cell` fallback (graph.ts:164)
  β€” defensive return when `alphabets[tapeIx]` is missing

Plus the parser-fallback test in `parsePatternString` describe block
(graph.ts:173) was already added in #171's first round; this PR
finishes the symmetric `parseWriteSymbolLabel` describe block.

Coverage: statements 98.72 β†’ 99.14 (+0.42),
branches 96.13 β†’ 96.71 (+0.58), lines 98.32 β†’ 99.21 (+0.89),
State.ts 99.11 β†’ 100% statements.

Should clear Coveralls' remaining -0.5% drop on PR #167 by pulling v7
total above master.

Remaining uncovered (not worth synthetic tests):
- graphFormats.ts:344 β€” defensive throw inside `stripBrackets`
  closure, unreachable via fromMermaid's slice logic
- introspection.ts:121 β€” `if (node)` guard in cycle detection
@mellonis mellonis merged commit 1aab2a6 into v7 May 20, 2026
1 check passed
@mellonis mellonis deleted the chore/coverage-bump-v7-2 branch May 20, 2026 21:53
@github-project-automation github-project-automation Bot moved this from Todo to Done in @mellonis's machines May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant