test: cover IVector*/Magnitude/Dot/Cross and semantic overload conversions#66
Merged
matt-edmondson merged 1 commit intovectorsfrom May 9, 2026
Merged
test: cover IVector*/Magnitude/Dot/Cross and semantic overload conversions#66matt-edmondson merged 1 commit intovectorsfrom
matt-edmondson merged 1 commit intovectorsfrom
Conversation
Add Semantics.Test/Quantities/ with two test classes that exercise the unified-vector physics surface end-to-end: VectorQuantityTests (issue #54) - Velocity3D.Magnitude(3,4,0) == Speed(5). - Force3D.Magnitude with negative components is non-negative. - Magnitude statically returns the V0 base type (Speed for Velocity3D). - Cross-dimensional Dot: Force3D.Dot(Displacement3D) == Energy. - Cross-dimensional Cross: Force3D.Cross(Displacement3D) == Torque3D, with perpendicular and parallel cases. - Same-dimension Dot returns the raw storage scalar (no "Speed²" type). - Vector arithmetic preserves dimension and is componentwise. - Velocity1D.Magnitude on negative values returns positive Speed (T.Abs). - V0 + V0 stays the same V0. SemanticOverloadTests (issue #55) - Implicit widening of overloads to base (Weight -> ForceMagnitude, Distance/Diameter -> Length). - Explicit narrowing from base (ForceMagnitude -> Weight, Length -> Distance). - From(base) factory. - Round-trip widen/narrow preserves value. - Diameter <-> Radius via metadata-defined relationships. - Float and decimal storage genericity sanity checks. Two ignored tests serve as TDD targets tied to open issues: - Mass(3) - Mass(5) should return Mass(2), not Mass(-2): tracked in #52. - Speed.FromMetersPerSecond(-1) and Mass.FromKilogram(-1) should throw ArgumentException: tracked in #50. The Weight - Weight subtraction currently returns Force1D (the generator's old "option 4" choice). The test documents that behaviour and links the follow-up work to #52.
|
Merged
3 tasks
This was referenced May 9, 2026
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 #54 and #55.
Adds
Semantics.Test/Quantities/with two test classes that exercise the unified-vector physics surface end-to-end. No source-generator changes — these tests run against today's emitted code.VectorQuantityTests(#54)Velocity3D(3,4,0).Magnitude() == Speed(5); works on negative components (Force3D(-3,-4,0).Magnitude() == 5); statically returns the V0 base type; zero vector → zero magnitude.Force3D.Dot(Displacement3D) == Energy(aligned and perpendicular cases);Force3D.Cross(Displacement3D) == Torque3D;f.Cross(f) == zero.+,-, unary-preserve dimension and are componentwise.SemanticOverloadTests(#55)Weight → ForceMagnitude,Distance/Diameter → Length.(Weight)forceMagnitude,(Distance)length.From(base)factory:Weight.From(forceMagnitude),Distance.From(length).Diameter ↔ Radiusvia metadata-defined relationships.float,decimal).Ignored tests (TDD targets for open issues)
Mass(3) - Mass(5)should returnMass(2)per the locked decision in Resolve open design decision for Vector0 subtraction #52 — currently returnsMass(-2)because the V0 base subtraction is plain.Speed.FromMetersPerSecond(-1)andMass.FromKilogram(-1)should throwArgumentExceptionper Vector0 quantities do not enforce the non-negativity invariant #50 — generator currently emits no guard.These tests are marked
[Ignore]with a message linking to the issue, so they don't fail CI today but become unignored when the corresponding fix lands.The
Weight - Weightsubtraction currently returnsForce1D(the generator's old "option 4" choice from the original strategy doc). One test documents that behaviour and notes #52 as the follow-up — when #52 is implemented, this test will be replaced with the correctWeight - Weight => Weightshape.Test plan
[Ignore]tests pass (they exercise existing API).[Ignore]tests appear in the runner output as skipped, with the issue numbers visible.🤖 Generated by Claude Code
Generated by Claude Code