Repository navigation
test: dedupe LogNormal fixture and assert error messages (#100) - #146
Merged
Merged
Conversation
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.
Contributor
Try this Pull Request!Option 1: Julia Package ManagerOpen 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 ModifiedDistributionsOption 2: Local CheckoutIf you have the repo locally: git checkout test/fixtures-and-messages-100
julia --project=. -e "using Pkg; Pkg.instantiate()" |
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
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. |
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
Closes test-depth gaps 7 and 8 from #100, scoped to
test/Affine.jl,test/Transformed.jlandtest/interfaces.jl(a parallel agent ownstest/Modified.jl/test/Weighted.jlfor the same gaps and was nottouched here).
Gap 7 — copy-pasted setup.
LogNormal(1.5, 0.5)was reconstructedas a literal throughout these three files. Added a
BaseDistFixture@testsnippet(test/fixtures.jl) providingbase_dist(), pulledinto every relevant
@testitemviasetup=[BaseDistFixture].TestItemRunner collects
@testsnippets package-wide by name (seerun_testiteminTestItemRunner.jl), so the snippet is reachablefrom any file, not only the one that defines it — it is ready for
Modified.jl/Weighted.jlto adopt via the samesetup=[...]mechanism, no new machinery needed.
interfaces.jl's existingModifierFixturessnippet alreadydeduplicated the literal within its own file; its
modifier_fixturesfunction now takes
baseas a parameter instead of constructing itsown, since
@testsnippets cannotsetup=each other.Gap 8 —
@test_throws Typewith no message check. Everyvalidation-error test in these two files now asserts exact message
content via
@test_throws ArgumentError("...") expr(checked byisequalin Test.jl), not just the exception type. This covers:Affine's scale-must-be-positive checkTransformed's thin-probability-range checkintensity/effective_intensityerrorbranches (no-declared-factor vs needs-composed-tree)
The source messages in
src/Affine.jl,src/Transformed.jlwerealready distinct per branch — no
src/changes were needed to makegap 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:
LogNormal(1.5, 0.5)literals intest/Modified.jlandtest/Weighted.jlwithsetup=[BaseDistFixture]+base_dist().test/Weighted.jl:17,571andtest/Modified.jl:26,30,33,37from
@test_throws ArgumentErrorto@test_throws ArgumentError("...")with the exact source message. The 4
ArgumentErrorbranches insrc/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 passedtask test-quality(Aqua/formatting/JET/doctests): 116 passedtask test-formatting: all files formattedAffine.jl/Transformed.jl/interfaces.jl/fixtures.jlrun: 361 passed
This was opened by a bot. Please ping @seabbs for any questions.