Repository navigation
Cover the paths nothing exercised (94% -> 99% statements, 77% -> 97% branches) - #11
Merged
Merged
Conversation
Coverage went in measuring 93.98% of statements and 77.06% of branches. This takes it to 99.14% and 97.31%, and what is left is unreachable rather than untested. - Every way the parser can refuse an application identifier, 32 messages in all. Several are reached only by a barcode which stops in the middle of an AI, where the digit the switch is about to read is not there at all: a real scan of a damaged code, and previously not exercised once. - The five symbology identifiers besides ]C1, and the path for a barcode arriving without one. - Elements carrying an ISO code, which behave differently depending on whether they end at a separator or run to the end of the barcode. - The sliding year window, worked out from the current year rather than hard coded, so the specs do not start failing on their own some year from now. Three identifier families the parser supports were missing from the table that is supposed to hold all of them: 703x PROCESSOR, 723x CERT and 8026 ITIP CONTENT. They build their AI by concatenation, so the extraction which first produced that table never saw them. The case for code "38" is removed from the message switch. checkDeclaredAIs runs after the parse loop, outside the try which feeds that switch, so the arm could not be reached from anywhere; the message is thrown where the check is. Thresholds are raised to match. Merged with the person identifiers still in review this comes to 99.4% and 98.41%, so that change clears them too.
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.
#10 added the measurement. This closes what it found.
301 specs, 0 failures.
What is now covered
Every refusal. The big switch throws a two digit code which a switch at the bottom turns into a message, and nothing exercised either side of it — 32 messages, none of them pinned.
spec/RefusedIdentifiersSpec.jscovers all of them.Four were only reachable by a barcode that stops in the middle of an AI, where the digit the switch is about to read is not there at all —
]C132,]C134,]C136,]C19. That is an ordinary half-read scan, and no spec had ever sent one.The symbology identifiers.
]C1was the only one any spec used.]e0,]e1,]e2,]d2and]Q3are covered now, along with a barcode arriving without one at all.Elements carrying an ISO code, which take a different path depending on whether they end at a separator or run to the end of the barcode. Only the second was exercised.
The sliding year window. Worked out from the current year rather than hard coded, so these specs will not start failing on their own a few years from now.
Three identifiers were missing from the table
spec/ApplicationIdentifiersSpec.jsis meant to hold every supported identifier. It did not hold these:7030–7039PROCESSOR #7230–7239CERT #8026ITIP CONTENTAll three build their AI by concatenation —
parseVariableLength("723" + fourthNumber, …)— so the extraction that first produced that table never saw them. Added, following the table's existing convention of one representative per composed family.One piece of dead code removed
case "38"is gone from the message switch.checkDeclaredAIsruns after the parse loop, outside thetrythat feeds that switch, so the arm could never be reached from anywhere. The message is thrown where the check is, and there is now a comment saying why it does not go through the switch.What is left, and why it stays
Everything still uncovered is unreachable, not merely untested:
catcharms aroundparseIntandparseFloat— neither throws — and the messages they map to;defaultarm of the element type switch, since every caller passes a known type;defaultarm of the message switch, since every code in use has an arm of its own;Deleting those would be a change to the parser rather than to its specs, so they are documented in the README instead.
Thresholds
Raised to 99% statements and lines, 97% branches, 100% functions.
Checked against #9 before setting them: merged with the person identifiers this comes to 99.4% and 98.41%, so that PR clears the new thresholds rather than being blocked by them.
Found along the way, not fixed here
Two things worth their own change:
]C1430,]C1701,]C1230and 23 others — comes back as a successful parse whose single element is the empty string, because those inner switches have nodefault. Same shape as the fall-through fixed in Fix switch fall-through breaking 46 application identifiers, add full AI coverage and CI #6.]C143reports "invalid AI after '42'". Two different defaults throw the same internal code. There is a spec pinning the current message with a comment saying it is wrong, so correcting it fails loudly and gets updated on purpose.