Skip to content

test: dedupe LogNormal fixture and assert error messages (#100) - #146

Merged
seabbs merged 1 commit into
mainfrom
test/fixtures-and-messages-100
Aug 12, 2026
Merged

seabbs merged 1 commit into
mainfrom
test/fixtures-and-messages-100

Conversation

@seabbs-bot

Copy link
Copy Markdown
Collaborator

Summary

Closes test-depth gaps 7 and 8 from #100, scoped to test/Affine.jl,
test/Transformed.jl and test/interfaces.jl (a parallel agent owns
test/Modified.jl / test/Weighted.jl for the same gaps and was not
touched here).

Gap 7 — copy-pasted setup. LogNormal(1.5, 0.5) was reconstructed
as a literal throughout these three files. Added a BaseDistFixture
@testsnippet (test/fixtures.jl) providing base_dist(), pulled
into every relevant @testitem via setup=[BaseDistFixture].
TestItemRunner collects @testsnippets package-wide by name (see
run_testitem in TestItemRunner.jl), so the snippet is reachable
from any file, not only the one that defines it — it is ready for
Modified.jl/Weighted.jl to adopt via the same setup=[...]
mechanism, no new machinery needed.

interfaces.jl's existing ModifierFixtures snippet already
deduplicated the literal within its own file; its modifier_fixtures
function now takes base as a parameter instead of constructing its
own, since @testsnippets cannot setup= each other.

Gap 8 — @test_throws Type with no message check. Every
validation-error test in these two files now asserts exact message
content via @test_throws ArgumentError("...") expr (checked by
isequal in Test.jl), not just the exception type. This covers:

  • Affine's scale-must-be-positive check
  • Transformed's thin-probability-range check
  • the three distinguishable intensity/effective_intensity error
    branches (no-declared-factor vs needs-composed-tree)

The source messages in src/Affine.jl, src/Transformed.jl were
already distinct per branch — no src/ changes were needed to make
gap 8's "distinguishable message" requirement true for these files.

Remaining for a follow-up (Modified.jl / Weighted.jl)

Out of scope here (owned by another agent on #100), but ready to pick
up with the fixture in place:

  • Replace LogNormal(1.5, 0.5) literals in test/Modified.jl and
    test/Weighted.jl with setup=[BaseDistFixture] + base_dist().
  • Strengthen test/Weighted.jl:17,571 and test/Modified.jl:26,30,33,37
    from @test_throws ArgumentError to @test_throws ArgumentError("...")
    with the exact source message. The 4 ArgumentError branches in
    src/Modified.jl:269-291 (per-bin-vector-needs-discrete,
    discrete-needs-per-bin-vector, continuous-needs-scalar-or-callable,
    additive-hazard-needs-finite-lower-bound) and
    src/Weighted.jl:49,165 (weight-must-be-non-negative,
    mismatched-lengths) all already have distinct, specific messages, so
    no src/ changes are needed there either.

Test plan

  • task test-fast (skip-quality suite): 2194 passed
  • task test-quality (Aqua/formatting/JET/doctests): 116 passed
  • task test-formatting: all files formatted
  • Targeted Affine.jl/Transformed.jl/interfaces.jl/fixtures.jl
    run: 361 passed

This was opened by a bot. Please ping @seabbs for any questions.

Gap 7: LogNormal(1.5, 0.5) was reconstructed as a literal throughout
test/Affine.jl, test/Transformed.jl and test/interfaces.jl. Add a
`BaseDistFixture` @testsnippet (test/fixtures.jl) providing base_dist(),
and pull it into every @testitem in these three files via
setup=[BaseDistFixture]. TestItemRunner collects @testSnippets
package-wide by name, so the snippet is reachable from any file, not
only the one that defines it — this makes it ready for Modified.jl and
Weighted.jl to adopt in a follow-up (they are out of scope here, owned
by another agent on this issue). interfaces.jl's ModifierFixtures
snippet now takes `base` as a parameter, since @testSnippets cannot
setup= each other.

Gap 8: @test_throws ArgumentError with no message check let a branch
throwing the right type for the wrong reason pass silently. Assert
exact message content (`@test_throws ArgumentError("...") expr`, which
Test.jl checks by isequal) for every validation error in these two
files: Affine's scale-must-be-positive, Transformed's thin-probability
range check, and the three distinguishable intensity/effective_intensity
error branches.
@github-actions

Copy link
Copy Markdown
Contributor

Try this Pull Request!

Option 1: Julia Package Manager

Open Julia and type:

import Pkg
Pkg.activate(temp=true)
Pkg.add(url="https://github.com/EpiAware/ModifiedDistributions.jl", rev="test/fixtures-and-messages-100")
using ModifiedDistributions

Option 2: Local Checkout

If you have the repo locally:

git checkout test/fixtures-and-messages-100
julia --project=. -e "using Pkg; Pkg.instantiate()"

@codecov

codecov Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
ad-enzyme-forward 27.14% <ø> (ø)
ad-enzyme-reverse 27.14% <ø> (ø)
ad-forwarddiff 16.16% <ø> (ø)
ad-mooncake-forward 16.16% <ø> (ø)
ad-mooncake-reverse 16.16% <ø> (ø)
ad-reversediff 16.16% <ø> (ø)
unit 97.42% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Documentation preview is ready!

View the docs for this PR at: https://EpiAware.github.io/ModifiedDistributions.jl/previews/PR146/

This preview will be updated automatically when you push new commits.

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