Repository navigation
Expand parser/token edge-case test coverage for error recovery, whitespace filtering, and null-state branches - #32
Conversation
Co-authored-by: fupacat <595487+fupacat@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The change is additive, test-only with no production behavior change, and each new assertion was verified to match the existing production code.
0 open findings
What changed in this PR
This PR adds focused unit tests to close SonarCloud coverage gaps in the tsql-scriptdom-core parser/token utilities (issue #29). No production code is modified; the tests exercise previously uncovered branches in parser error recovery, quoted-identifier initialization, whitespace/comment filtering boundaries, and null/error-state handling in lightweight value objects. I verified each new assertion against the corresponding production code (TSqlWhitespaceTokenFilter, TSqlParserToken, TSql180Parser, ParseResult) and found them consistent with actual behavior; imports are present, and every TRACEABILITY_MAPPING references a requirement that exists in context/SRS.md.
Changes:
- Adds
TSql180ParserTestcases forparse(null, errors), malformed-SQL error collection, and both quoted-identifier constructor paths. - Extends
TSqlWhitespaceTokenFilterTestwith adjacent-comment/EOF-boundary, inner-stream skip-to-EOF, andAsciiStringOrQuotedIdentifierconversion-flag tests. - Adds a null-token-type fallback test (
TSqlParserTokenTest) and a newParseResultTestcovering null/non-empty error branches and immutability.
| File | Description |
|---|---|
| tsql-scriptdom-core/src/test/java/io/github/fupacat/TSql180ParserTest.java | Adds null-reader, syntax-error, and quoted-identifier constructor coverage. |
| tsql-scriptdom-core/src/test/java/io/github/fupacat/TSqlWhitespaceTokenFilterTest.java | Adds list-backed and inner-stream filter edge cases plus conversion-flag checks. |
| tsql-scriptdom-core/src/test/java/io/github/fupacat/TSqlParserTokenTest.java | Adds null token-type fallback to None/ANTLR type 0. |
| tsql-scriptdom-core/src/test/java/io/github/fupacat/ParseResultTest.java | New test for null/non-empty error branches, immutability, and toString. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| TSqlFragment fragment = parser.parse(new StringReader("SELECT FROM WHERE;"), errors); | ||
|
|
||
| assertThat(fragment).isNotNull(); |

Coverage gaps existed in core parsing/token utilities around parser error recovery, quoted-identifier initialization paths, whitespace/comment filtering boundaries, and null/error-state branches in lightweight value objects. This PR adds focused unit tests to exercise those branches without changing production behavior.
Parser recovery + constructor-path coverage (
TSql180ParserTest)parse(null, errors)returningnullwithout mutating error state.TSql180Parser(true)andTSql180Parser(false)constructor paths to cover quoted-identifier initialization toggles.Whitespace/comment filter edge cases (
TSqlWhitespaceTokenFilterTest)AsciiStringOrQuotedIdentifierconversion behavior under quoted-identifier on/off modes.Token + parse-result null/error branches
TSqlParserTokenTest: addsnulltoken-type constructor case to validate fallback toTSqlTokenType.Noneand underlying ANTLR type0.ParseResultTest(new): adds null-errors/immutable-empty-list and non-empty-errors branches, includingisSuccess()/hasErrors()/toString()behavior.