fix(assertion-eval): count() comparisons evaluate correctly (v0.9.x bug closeout)#218
Open
avrabe wants to merge 1 commit into
Open
fix(assertion-eval): count() comparisons evaluate correctly (v0.9.x bug closeout)#218avrabe wants to merge 1 commit into
avrabe wants to merge 1 commit into
Conversation
…ug closeout) The assertion DSL silently rejected pipelines ending in `.count() <op> n` (`>=`, `>`, `<=`, `<`, `==`, `!=`) because the lexer had no tokens for the comparison operators or integer literals, and the parser had no production that combined them with a pipeline. Extends the assertion grammar with: - Lexer: NEQ, GE, GT, LE, LT, INT_LIT tokens. - Syntax: 6 new comparison-op kinds + COUNT_COMPARE_EXPR node. - Parser: lookahead wraps a pipeline followed by `<op> <int>` in a COUNT_COMPARE_EXPR at the ROOT level. - Eval: eval_count_compare unwraps Value::Count / Components / Features / Diagnostics into a usize and returns Value::Bool. 7 new tests cover all 6 comparison operators against a 2-thread fixture. Closes the v0.9.x bug where \`components.where(...).count() >= n\` was unusable in [[assertion]] blocks. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4 tasks
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.
Summary
The assertion DSL silently rejected pipelines ending in
.count() <op> n(>=,>,<=,<,==,!=) because the lexer had no tokens for the comparison operators or integer literals, and the parser had no production combining them with a pipeline. Users couldn't express cardinality constraints in[[assertion]]blocks.MWE
Pre-fix: parse error. Post-fix: evaluates to
Value::Bool.What changed
NEQ,GE,GT,LE,LT,INT_LIT.COUNT_COMPARE_EXPRnode.<op> <int>in aCOUNT_COMPARE_EXPRat the ROOT level.eval_count_compareunwrapsValue::{Count, Components, Features, Diagnostics}into ausizeand returnsValue::Bool.Test plan
crates/spar-cli/src/assertion/mod.rs(eval_count_ge_true / _false, _gt, _le, _lt, _eq, _neq) — all passcargo clippy -p spar -- -D warningscleaneval_counttest still passes (unchanged behavior)Part of v0.9.x bug closeout series (#214 nested binding, #216 classifier_match, #217 has-features).
Co-Authored-By: Claude Opus 4.7 noreply@anthropic.com