Add SubsetOf conversion tests for DualVec#78
Merged
Conversation
PR #38 added the simba SubsetOf impls for DualVec<F, N> but left them untested. nalgebra's matrix operations satisfy the ComplexField / RealField bounds without exercising is_in_subset / from_superset at runtime, so a regression in the conversion logic — e.g. is_in_subset no longer rejecting live tangents — would pass silently. Cover all five impls (identity, f64/f32 embedding, and both cross-precision conversions), exercising to_superset, from_superset_unchecked, is_in_subset (accept and reject cases), and from_superset. The cross-precision test uses a non-f32-representable value so the lossy narrowing is genuinely verified.
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
SubsetOfimpls forDualVec<F, N>introduced in Implementation of simba traits for DualVec #38 — identity,f64/f32embedding, and both cross-precision conversions.to_superset,from_superset_unchecked,is_in_subset(both the accept and the live-tangent reject case for every scalar impl), andfrom_superset. nalgebra's matrix operations satisfy theComplexField/RealFieldbounds without calling these at runtime, so a regression in the conversion logic — e.g.is_in_subsetno longer rejecting live tangents — would otherwise pass silently.f32-representable value, so the lossyf64→f32narrowing is genuinely verified (assert_ne!on the round-trip) rather than only asserted in prose.Test-only change — no user-facing behaviour, so no CHANGELOG entry.
Test plan
cargo test— full suite passes (CI feature set);nalgebra_integrationhas 17 tests incl. 4 newcargo fmt --checkcleancargo clippy --all-targets -- -D warningsclean