Skip to content

Replace meval with evalexpr, add tests and CI (0.1.12)#2

Merged
binarypie merged 2 commits into
mainfrom
claude/datacube-calculator-evalexpr
Jun 14, 2026
Merged

Replace meval with evalexpr, add tests and CI (0.1.12)#2
binarypie merged 2 commits into
mainfrom
claude/datacube-calculator-evalexpr

Conversation

@binarypie

@binarypie binarypie commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Two related changes:

  1. Calculator: mevalevalexpr. meval 0.2 is unmaintained and pulled in an ancient nom 1.2 that triggered a future-incompatibility warning. Switched to the actively maintained evalexpr, removing that warning.
  2. Test coverage + CI. Added unit/integration tests across the codebase and a GitHub Actions workflow to run them.

Calculator behaviour preserved

evalexpr differs from meval in two ways that matter for a calculator; both are handled so existing expressions keep working:

  • Float division. evalexpr does integer division for integer operands (5/2 == 2). Bare integer literals are coerced to floats before evaluation so arithmetic behaves like a calculator (5/2 == 2.5). Digits that belong to identifiers (the 10 in log10) or decimal literals (3.14) are left untouched.
  • Functions & constants. evalexpr only exposes math functions under a math:: namespace and ships no math constants. A custom evaluation context registers the familiar bare names (sqrt, sin, cos, tan, ln, log, log2, log10, exp, abs, floor, ceil, round, pow, ...) and the constants pi, e, tau.

Division by zero still yields Infinity, matching the previous f64 behaviour.

Tests

cargo test now runs 30 tests:

  • calculator — literal floatification, arithmetic, functions/constants, error handling, result formatting
  • applicationsAppSource detection, .desktop parsing (incl. NoDisplay / missing-Exec skips), bulk loading from an extra dir, query matching (name, id, no-match, empty-query truncation)
  • config — defaults, TOML round-trip, serde fallback for partial/empty configs
  • providersItem builder and Item / ProviderInfo → protobuf conversions
  • manager — registration, score-based combining/sorting, max_results truncation, explicit-provider filtering, prefix routing (via a mock provider)
  • server — end-to-end query and list-providers round-trips over a real Unix socket

CI

Adds .github/workflows/ci.yml — on pushes to main and on PRs it installs protoc, then runs cargo fmt --check, cargo build --locked, and cargo test --locked.

Verification

  • cargo build --release --locked
  • cargo test ✅ (30 passed)
  • cargo fmt --all -- --check
  • meval and the old nom 1.2 are gone from Cargo.lock; future-incompat warning resolved

Bumps version to 0.1.12 (Cargo.toml + datacube.spec).

https://claude.ai/code/session_01B33sAdjSZQQ6XRtFkxYTAb

claude added 2 commits June 14, 2026 14:22
meval 0.2 is unmaintained and pulled in an ancient nom 1.2 that triggers a
future-incompatibility warning. Switch the calculator to the actively
maintained evalexpr crate, removing that warning.

evalexpr differs from meval in two ways that matter for a calculator, both
handled here to preserve the existing behaviour:

- Integer operands use integer division (5/2 == 2). Bare integer literals are
  coerced to floats before evaluation so arithmetic behaves like a calculator
  (5/2 == 2.5). Digits that belong to identifiers (e.g. the 10 in log10) or
  decimal literals (3.14) are left untouched.
- Math functions are only exposed under a math:: namespace and there are no
  math constants. A custom evaluation context registers the familiar bare
  names (sqrt, sin, cos, tan, ln, log, log2, log10, exp, abs, floor, ceil,
  round, pow, ...) and the constants pi, e and tau.

Division by zero still yields Infinity, matching the previous f64 behaviour.

Added unit tests covering literal floatification, arithmetic, functions,
constants and error handling.

https://claude.ai/code/session_01B33sAdjSZQQ6XRtFkxYTAb
Expands test coverage beyond the calculator:

- applications: AppSource detection, .desktop parsing (including NoDisplay /
  missing-Exec skips), bulk loading from an extra dir, and query matching
  (by name, by id, no-match, empty-query truncation)
- config: defaults, TOML round-trip, and serde fallback for partial/empty
  configs
- providers: Item builder and Item/ProviderInfo -> protobuf conversions
- manager: provider registration, score-based combining/sorting, max_results
  truncation, explicit-provider filtering, and prefix routing (via a mock
  provider)
- server: end-to-end query and list-providers round-trips over a real Unix
  socket

Adds .github/workflows/ci.yml running fmt check, build and test on pushes to
main and on pull requests (installs protoc and uses --locked).

https://claude.ai/code/session_01B33sAdjSZQQ6XRtFkxYTAb
@binarypie binarypie changed the title Replace meval with evalexpr in the calculator provider (0.1.12) Replace meval with evalexpr, add tests and CI (0.1.12) Jun 14, 2026
@binarypie binarypie merged commit d1bae86 into main Jun 14, 2026
1 check 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.

2 participants