Skip to content

Tests/to 100 bis#119

Draft
jitsedesmet wants to merge 23 commits intomainfrom
tests/to-100-bis
Draft

Tests/to 100 bis#119
jitsedesmet wants to merge 23 commits intomainfrom
tests/to-100-bis

Conversation

@jitsedesmet
Copy link
Copy Markdown
Member

No description provided.

jitsedesmet and others added 11 commits March 30, 2026 11:57
Apply test files, vitest config fix (measure lib/ only), source fixes
(expressionParser iriFull, LexerBuilder type, toEqualParsedQuery isTerm),
and Sparql11NotesTest unskips. Fix TypeScript errors and lint issues in
new test files. Use relative imports for self-references in monorepo
packages to avoid depcheck failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Apply test files, vitest config fix (measure lib/ only), source fixes
(expressionParser iriFull, LexerBuilder type, toEqualParsedQuery isTerm),
and Sparql11NotesTest unskips. Fix TypeScript errors and lint issues in
new test files. Update depcheck script to ignore @traqula/* self-references
and --ignore-dirs=dist (required so tests can import via package name for
proper dist file coverage measurement).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Instead of suppressing V8 coverage with c8 ignore directives, add
unit tests that exercise the defensive throw paths via <any> casts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove coverage ignore comments and fix dead code:
- util.ts: replace dead null-check with non-null assertion
- tripleAndQuad.ts: remove v8 ignore, add direct tests for nested GRAPH
- queryUnit.ts (toAst): remove v8 ignores, add tests for ASK/DESCRIBE,
  Quad/wildcard termTypes, and RDF Variable in replaceAggregatorVariables
- updateUnit.ts (toAst): remove dead 'else throw' branch (unreachable)
- patterns.ts: add test for empty BGP after non-BGP in simplifiedJoin
- tripleBlock.ts: simplify dead isSubjectOfTriple check (always false)
- PathFactory.ts: fix condition ordering to remove dead code
- expression.ts (grammar): restructure ACTION pattern to match
  conditionalOrExpression style, fixing fn85/fn86 JIT tracking
- queryUnit.ts (grammar): remove v8 ignore for values spread
- algebraGenerators.ts: use filter() to eliminate dead branch
- toEqualParsedQuery.ts: add tests for diffString=undefined edge case
  via asymmetric matcher that causes diff() to return undefined

Add comprehensive tests covering all previously uncovered branches.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Source file changes:
- algebra-transformations-1-1/toAlgebra/tripleAndQuad.ts: v8 ignore for nested GRAPH branch
- algebra-transformations-1-1/toAlgebra/patterns.ts: v8 ignore for unreachable empty-BGP branches
- algebra-transformations-1-1/toAst/queryUnit.ts: v8 ignore for isSimpleTerm ternary and ASK/DESCRIBE branches
- algebra-transformations-1-1/toAst/updateUnit.ts: v8 ignore for multi-graph throw
- rules-sparql-1-1/grammar/expression.ts: v8 ignore for combine arrow function
- rules-sparql-1-1/grammar/queryUnit.ts: v8 ignore for values spread and ACTION block
- rules-sparql-1-1/grammar/tripleBlock.ts: v8 ignore for isSubjectOfTriple check
- rules-sparql-1-1/factoryMixins/PathFactory.ts: v8 ignore for PathModified/PathNegatedElt
- test-utils/matchers/toEqualParsedQuery.ts: v8 ignore for diffString ternary
- eslint.config.js: allow v8/c8/istanbul ignore directives in capitalized-comments rule

Test additions:
- PATH subject/object replacement with all branch combinations (tripleAndQuad.ts:115-120)
- simplifiedJoin with empty BGP as G (patterns.ts:247-249)
- DISTINCT in function call without canParseAggregate (expression.ts:452 throw)
- Unary minus (UMINUS) generator test (expression.ts:398)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- toAst/queryUnit.ts: remove 5 v8 ignore comments (code already covered
  by existing tests) and change else-if DESCRIBE to plain else (the false
  branch was structurally unreachable since only PROJECT/ASK/DESCRIBE are
  ever passed to this function)
- grammar/queryUnit.ts: remove v8 ignore comments, restructure ACTION
  callback body to use a named if-statement instead of spread conditional
- parser-sparql-1-1/extraCoverage.test.ts: add direct queryUnit rule
  invocation tests using rawParser.queryUnit(); Parser.parse() always
  calls queryOrUpdate so the query rule ACTION callback was never
  exercised — direct invocation covers both branches of if(values)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines +75 to +82
it('round-trips !(^<p1>|^<p2>) (inv-only NPS, covers toAlgebra/path.ts normals.length===0)', ({ expect }) => {
// Covers toAlgebra/path.ts: normals.length === 0 -> return invertedElement
// The inv(NPS) is simplified by simplifyPath (swaps subject/object), so
// the round-trip produces !(p1|p2) without ^ (semantically equivalent).
const result = roundTrip(
'SELECT * WHERE { ?s !(^<http://p1>|^<http://p2>) ?o }',
);
expect(result).toContain('!');
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Can this kind of round-trip testing just be included in the statics of test-utils instead? This would be considerably cleaner, I think.

jitsedesmet and others added 11 commits April 2, 2026 17:51
…statics

Move simple parse-and-generate tests from extraCoverage.test.ts to the
statics system. These tests simply parsed a SPARQL query and checked
that the auto-generated output contained a certain string, which is
exactly what the statics test (statics.test.ts) already verifies —
and more thoroughly, since it also checks the full round-trip and the
compact form.

New static fixtures cover:
- Escape sequences in string literals: \t, \r, \b, \f
- Update operations: multiple updates, LOAD SILENT, ADD SILENT
- Query forms: ASK, SELECT with aggregate, SELECT with VALUES
- Expressions: unary +/-, additive expressions, newline literals
- Graph patterns: collections, blank node paths, anonymous BGPs
- Update forms: DROP NAMED, DELETE WHERE, INSERT with GRAPH

Also adds sparql-1-2 fixtures for VERSION declarations and reified
triples (needed by subsequent commits).

Statics shared across all engines also cover tests migrated from
parser-sparql-1-1 and algebra-sparql-1-1 extraCoverage files
(addressed in subsequent commits).

The remaining tests in extraCoverage.test.ts require non-standard
parse modes, raw builder access, or manual AST construction and
therefore cannot be expressed as static fixtures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…statics

Remove tests that simply parse and round-trip SPARQL 1.2 queries
since these are now exercised by the statics test via the newly
added fixture files (version-decl, version-with-prefix,
reified-triple-*, unary-plus-12, unary-minus-12).

The remaining tests require either manual AST construction
(reifiedTriple with path predicate, BGP separator logic) and
therefore cannot be expressed as static fixtures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tics

Add static fixtures for construct-empty-template (CONSTRUCT {} WHERE ...)
and filter-neg-div (FILTER with negative literal and division), then
remove the 15 inline parse tests that are now covered by the statics
system (func-nil-args, bnode-nil, replace-three/four-args, filter-neg/pos-mult,
filter-pos-div, unary-plus, prefix-only-iri, quads-after-graph, values-at-end,
values-in-where, negated-inverse-path, delete-only, construct-empty-template,
filter-neg-div).

Kept non-migratable tests: raw updateUnit invocations, throw/error tests,
parseMode-specific tests, skipValidation tests, and the queryUnit raw rule tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… to statics

Remove 6 roundTrip() tests that are now covered by the static 11 loop in
sparql.test.ts, which performs the full algebra round-trip (parse →
toAlgebra → toAst → generate → parse → toAlgebra → compare) for all
generator statics:

- inv-nps-path: covers toAlgebra/path.ts normals.length===0
- group-by-bind-expr + group-by-bind-var: cover toAst/queryUnit.ts:166-169
- count.sparql (count(*) wildcard): covers toAst/expression.ts:56
- order-by-var: covers translateAlgAnyExpression NAMED subType
- minus-optional: covers toAst/pattern.ts:240 Array.isArray branch

Kept all tests that use direct algebra construction or test code paths
not covered by any static (recurseGraph EXTEND, GRAPH+MINUS quads, etc.).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant