Skip to content

test: Guard derived values typed as integers - #395

Open
mhovd wants to merge 1 commit into
mainfrom
mhovd-test-dsl-integer
Open

mhovd wants to merge 1 commit into
mainfrom
mhovd-test-dsl-integer

Conversation

@mhovd

@mhovd mhovd commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Adds regression tests for whole-number derived values, which were read back as their f64 bit pattern (4.607182e18 for 1.0) on pharmsol < 0.29.3.

Fixed upstream in LAPKB/pharmsol#372; these tests pin the numbers so it cannot return silently.

A derived value whose initialiser folds to a whole number was typed `Int` by
the pharmsol DSL front end, while its slot lives in the runtime's f64 buffer.
The backend then stored a double and read it back as an integer, so the value
came out as its own f64 bit pattern (4.607182e18 for 1.0). Outputs,
conditionals and derivatives built from it were garbage, which is what drove a
reported model to 10^19.

pharmsol-dsl 0.29.3 (LAPKB/pharmsol#372) registers derived and output symbols
as real-valued. Pmetrics 3.2.6 pins pmcore 0.28.0 -> pharmsol 0.29.0 and is
affected; this branch pins pmcore 0.29.0 -> pharmsol 0.29.3 and is not.

These tests pin the numbers the compiled DSL produces for whole-number,
fractional and conditional derived values, so the regression cannot return
silently.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mhovd
mhovd requested review from Siel and a balanced review from Copilot October 2, 2026 18:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The tests accurately cover the reported regression and relevant execution paths.

Review effort: Balanced
Findings: None

What changed in this PR

Adds regression coverage ensuring whole-number derived DSL values retain floating-point semantics.

Changes:

  • Adds reusable simulation fixtures.
  • Tests output, conditional derivative, and direct derivative paths.
  • Includes a fractional-value control case.
File Description
tests/​testthat/​test-model-dsl-derived-constants.R Adds regression tests for derived-value typing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.77%. Comparing base (ef474a1) to head (9ee0cf0).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #395   +/-   ##
=======================================
  Coverage   64.77%   64.77%           
=======================================
  Files          52       52           
  Lines       22964    22964           
=======================================
  Hits        14876    14876           
  Misses       8088     8088           
🚀 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.

This branch has not been deployed

No deployments
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.

3 participants