test(coverage): cover remaining reachable v7 branches#172
Merged
Conversation
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
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.
Summary
Follow-up to #171 β three more tests for v7 lines that #171's parser-error tests didn't reach:
State.toGraphunbound-Referencecatch in WRAPPER context (State.ts:463-464). There are twotry/catchblocks for unboundReference.refintoGraphβ 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 viawithOverriddenHaltState(...)to exercise the second branch.parseWriteSymbolLabelfallback return (graph.ts:209) β defensive return-as-is for unrecognized labels. Symmetric with theparsePatternStringfallback that test(graphFormats): cover fromMermaid parser error pathsΒ #171 added.parsePatternStringblank-marker?? cellfallback (graph.ts:164) β defensive return whenalphabets[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 reportedCoverage decreased (-0.5%) to 97.805%). This PR adds the remaining reasonably-reachable branches.Coverage delta
State.tsstmtsgraph.tsstmtsMaster'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 astripBracketsclosure that's only called with slices the parser itself constructs from regex-matched[β¦]blocks. Not reachable via the publicfromMermaidAPI.introspection.ts:121βif (node)guard in cycle detection for a node that's in the color map but not ingraph.nodes. Can't happen withtoGraph-produced graphs.Test plan
npm testβ 431/431 pass (+3 from test(graphFormats): cover fromMermaid parser error pathsΒ #171's 428)npm run test:coverageβ numbers abovenpm run lintβ cleannpm run typecheckβ clean