test(expr): add coverage for Add, Mul, left-associativity, and null literal - #27
Merged
Merged
Conversation
…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.
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.
Why
BinOp::Add,BinOp::Mul, andLiteral::Nullare implemented in the parser (src/parser.rs) but have zero tests that verify the correct AST output. The only existing use ofRETURN 1 + 2in the test suite (tests/prune.rs) checks output column names, not the operator itself.Literal::Nullhas no test at all. This PR fills that gap.What
tests/expr.rs:parses_addition: verifiesRETURN 2 + 3producesBinary { op: Add, lhs: Int(2), rhs: Int(3) }parses_multiplication: verifiesRETURN 4 * 5producesBinary { op: Mul, lhs: Int(4), rhs: Int(5) }mul_binds_tighter_than_add:RETURN 2 + 3 * 4outer op is Add, rhs is Muladd_is_left_associative:RETURN 1 + 2 + 3lhs of outer Add is itself an Addparses_null_literal:RETURN nullproducesLiteral::Nullnull_is_case_insensitive: NULL, Null, null all produceLiteral::NullTests
cargo test- all tests pass (22 intests/expr.rs, full suite clean)cargo clippy --all-targets -- -D warnings- cleancargo fmt --check- cleanSelf-merge gate
src/lib.rsnot modified)tests/expr.rs, 6 new tests)Generated by Claude Code