From b973df418e0b32811b7e6ac8141cfc752b953b4a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 25 Nov 2026 22:20:54 +0100 Subject: [PATCH] Ymir test: an attachment alone refuses removal, and so does an anchor Each refusal stands alone: a box named only by an attachment, an anchor named only by an attachment, an anchor named only by a sensor. Pins the attachment loop in ymir_particles_release_body and that remove_body runs the reference check for anchors (Soul mutants M10, M11). Co-Authored-By: Claude Opus 5.5 --- .../Box3DSoaRemoveTests.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/Ymir.Box3D.Soa.Tests/Box3DSoaRemoveTests.cs b/tests/Ymir.Box3D.Soa.Tests/Box3DSoaRemoveTests.cs index 8fe958c..d5c5c4e 100644 --- a/tests/Ymir.Box3D.Soa.Tests/Box3DSoaRemoveTests.cs +++ b/tests/Ymir.Box3D.Soa.Tests/Box3DSoaRemoveTests.cs @@ -117,6 +117,36 @@ public sealed class Box3DSoaRemoveTests Assert.Equal(0, world.View.AttachmentCount == 0 ? 0 : world.View.AttachmentKind.ToArray().Count(k => k == (uint)Box3DSoaAttachKind.Body)); } + [Fact] + public void An_attachment_alone_refuses_removal_and_an_anchor_is_no_exception() + { + using var world = World(); + var box = world.AddBox(2, (0f, 2f, 0f), (0.1f, 0.1f, 0.1f), 500f); + var attached = world.AddAnchor(3, (1f, 2f, 0f)); + var sensed = world.AddAnchor(4, (2f, 2f, 0f)); + var p = new Box3DSoaParticleHandle[2]; + world.CreateParticles([new((0f, 2f, 0f), 0.02f, R), new((1f, 2f, 0f), 0.02f, R)], p); + var onBox = world.Attach(Box3DSoaAttachKind.Body, p[0], box, (0f, 0f, 0f)); + var onAnchor = world.Attach(Box3DSoaAttachKind.Body, p[1], attached, (0f, 0f, 0f)); + var sensors = new Box3DSoaConstraintHandle[1]; + world.CreateSensors([(sensed, (0f, 0f, 0f), 0.2f)], sensors); + Run(world, 3); + var before = Snapshot(world); + + Assert.Throws(() => world.RemoveBody(box)); // an attachment alone names it + Assert.Throws(() => world.RemoveBody(attached)); // an anchor named by an attachment + Assert.Throws(() => world.RemoveBody(sensed)); // an anchor named by a sensor + Assert.Equal(before, Snapshot(world)); + + world.Remove(onBox); + world.Remove(onAnchor); + world.Remove(sensors[0]); + world.RemoveBody(box); + world.RemoveBody(attached); + world.RemoveBody(sensed); + Assert.All(new[] { box, attached, sensed }, h => Assert.Equal((uint)Box3DSoaKind.Removed, world.View.Kind[h])); + } + [Fact] public void A_removed_anchor_ends_its_grab() {