Skip to content

test(expr): add coverage for Add, Mul, left-associativity, and null literal - #27

Merged
protosphinx merged 1 commit into
mainfrom
bot/add-mul-null-tests
Aug 26, 2026
Merged

protosphinx merged 1 commit into
mainfrom
bot/add-mul-null-tests

Conversation

@protosphinx

Copy link
Copy Markdown
Member

Why

BinOp::Add, BinOp::Mul, and Literal::Null are implemented in the parser (src/parser.rs) but have zero tests that verify the correct AST output. The only existing use of RETURN 1 + 2 in the test suite (tests/prune.rs) checks output column names, not the operator itself. Literal::Null has no test at all. This PR fills that gap.

What

  • 6 new tests appended to tests/expr.rs:
    • parses_addition: verifies RETURN 2 + 3 produces Binary { op: Add, lhs: Int(2), rhs: Int(3) }
    • parses_multiplication: verifies RETURN 4 * 5 produces Binary { op: Mul, lhs: Int(4), rhs: Int(5) }
    • mul_binds_tighter_than_add: RETURN 2 + 3 * 4 outer op is Add, rhs is Mul
    • add_is_left_associative: RETURN 1 + 2 + 3 lhs of outer Add is itself an Add
    • parses_null_literal: RETURN null produces Literal::Null
    • null_is_case_insensitive: NULL, Null, null all produce Literal::Null
  • Updated the module doc comment to list the newly covered operators.

Tests

  • cargo test - all tests pass (22 in tests/expr.rs, full suite clean)
  • cargo clippy --all-targets -- -D warnings - clean
  • cargo fmt --check - clean

Self-merge gate

  • all CI checks pass
  • LOC delta < 250 (diff is 110 lines)
  • no public-API surface change (src/lib.rs not modified)
  • no runtime-dependency additions
  • no workflow file changes
  • tests added or extended (tests/expr.rs, 6 new tests)

Generated by Claude Code

…iteral

BinOp::Add and BinOp::Mul are implemented in the parser but had no tests
verifying the correct AST output. Literal::Null also had no dedicated test.
Six new tests cover: Add lhs/rhs, Mul lhs/rhs, Mul-over-Add precedence,
Add left-associativity, null literal parse, and null case-insensitivity.
@protosphinx
protosphinx merged commit 0ae8126 into main Aug 26, 2026
3 checks passed
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