Repository navigation
test(joints): cover full-pool creates and five argument refusals - #350
Merged
Merged
Conversation
siracozmen01
commented
Nov 5, 2026
siracozmen01
left a comment
Collaborator
Author
There was a problem hiding this comment.
Review at b541721: ready. Read, not run.
The pool is filled through the public API.
def.jointCapacity = 1on the world def, then one revolute joint made withm2CreateRevoluteJoint, fills it.- The loop covers
m2_distanceJoint(0) tom2_ratchetJoint(10), the eleven contiguous values ofm2JointType.CreateJointOfTypenames ten of them and sends 10 to the ratchet throughdefault. - The second loop checks
m2Joint_GetType(world, joint) == type, so a helper that made the wrong type would be caught. - Each refusal must also leave
index1 == 0in place of{7, 7}, which proves the null id is written.
"No misuse" matches the docs.
world.hdefines misuse as "the bugs of the calling code: an argument a correct program never passes, a stale id, a writer called from host code the world is running".base.hdefinesm2_errorCapacityas a pool too small for the result, which a correct program can meet. So a full pool counts nothing, as the test expects.- The other test's refusals (NaN or infinite ranges and targets, a NaN ratio, a body joined to itself, a zero axis) are arguments a correct program never passes. They count one each, 7 in all, as
joint.hdocuments for the setters ("counts one misuse") and asm2_errorInvaliddoes for the creates. misuseCountis "not hashed or snapshotted", so checking the hash after misuse has been counted is sound.
Each assertion can fail, and the body has Problem, Change and Verification.
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.
Problem
A coverage run of main over every suite shows joint refusals a host can reach that no test takes. These are the full-pool create of seven joint types, and five argument checks: a distance joint's length range, a mouse target, a gear's ratio, a prismatic joint on one body and a wheel joint with no axis. A change to any of these branches would pass every suite (#349).
Change
test/test_joints.cgains two tests and a helper:CreateJointOfTypemakes one joint of any of the 11 types between two bodies from its default def.TestJointCreatesAtCapacity: a world whose one joint slot holds a revolute joint refuses each of the 11 types withm2_errorCapacityand the null id. It counts no misuse, and the world hash and joint count are unchanged. With the slot free, each type is made and has its type.TestJointArgumentRefusals:m2DistanceJoint_SetLengthRangewith a NaN minimum or an infinite maximum counts one misuse each and keeps the range.m2MouseJoint_SetTargetwith a NaN or infinite coordinate counts one misuse each and keeps the target.m2_errorInvalidand the null id, counting one misuse.A test-only change.
Verification
test_jointspasses.test_joints:tools/check.sh changedpasses. The changed file compiles clean with gcc-14 and clang-20 under the strict flags.test_goldenprints the 13 lines oftest/hashes.txtunchanged in the scalar (linux-clang-20-asan) and AVX2 (linux-clang-20) presets.Closes #349