Skip to content

Add regression coverage for XMILE right-nested non-commutative operators - #333

Merged
bpowers merged 1 commit into
mainfrom
github-mention-xmile-equation-printer-drops-parens-for-righ
Feb 25, 2026
Merged

bpowers merged 1 commit into
mainfrom
github-mention-xmile-equation-printer-drops-parens-for-righ

Conversation

@bpowers

@bpowers bpowers commented Feb 25, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The XMILE equation printer must preserve grouping for right-nested non-commutative operators so that expressions like a - (b - c) do not lose their parentheses and change semantics.
  • This patch hardens the existing parenthesization fix by adding focused regression tests to prevent regressions in future edits.

Description

  • Added assertions to test_print_eqn in src/simlin-engine/src/ast/mod.rs that verify print_eqn emits a - (b - c), a / (b / c), and a mod (b mod c).
  • The change only adds test coverage and does not alter the printer logic which is already handling right-child parenthesization for non-commutative operators.

Testing

  • Ran the targeted Rust unit test with cargo test -p simlin-engine test_print_eqn, which completed successfully.
  • The project pre-commit pipeline (Rust, TypeScript, and Python checks) was executed during the commit and passed, confirming the tests and workspace checks succeeded.

Codex Task

Add regression coverage for right-nested subtraction, division, and modulo in the XMILE equation printer. These cases are sensitive to associativity and must retain parentheses on the right child to preserve AST semantics.

The parenthesization logic is already implemented in this branch, so this change focuses on preventing future regressions and documenting the expected string output for non-commutative operators at equal precedence.
@bpowers
bpowers merged commit 94647e1 into main Feb 25, 2026
10 checks passed
@bpowers
bpowers deleted the github-mention-xmile-equation-printer-drops-parens-for-righ branch February 25, 2026 22:53
@claude

claude Bot commented Feb 25, 2026

Copy link
Copy Markdown

Code Review

Reviewed the diff: src/simlin-engine/src/ast/mod.rs (+42 lines, test-only)

Summary

This PR adds three regression test assertions to test_print_eqn covering right-nested non-commutative operators (Sub, Div, Mod). The tests verify that print_eqn correctly emits parentheses for expressions like a - (b - c), a / (b / c), and a mod (b mod c).

Findings

No bugs found. The test assertions correctly construct ASTs representing right-nested non-commutative expressions and verify the expected parenthesized output. The Loc span values match the expected string lengths, and the test structure is consistent with existing tests in the same function.

Verdict

Correct. The patch adds well-formed test coverage for existing parenthesization logic without modifying any production code. Existing code and tests will not break.

@codecov

codecov Bot commented Feb 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.61%. Comparing base (b714008) to head (3910af6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #333      +/-   ##
==========================================
+ Coverage   79.59%   79.61%   +0.01%     
==========================================
  Files         134      134              
  Lines       32650    32650              
==========================================
+ Hits        25989    25993       +4     
+ Misses       6661     6657       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant