diff --git a/tests/Lodur.Core.Tests/ActorPhysiologyTests.cs b/tests/Lodur.Core.Tests/ActorPhysiologyTests.cs
index e4ba6f7..47587d0 100644
--- a/tests/Lodur.Core.Tests/ActorPhysiologyTests.cs
+++ b/tests/Lodur.Core.Tests/ActorPhysiologyTests.cs
@@ -115,19 +115,22 @@ public sealed class ActorPhysiologyTests
[Fact]
public void A_dead_physiologys_flows_stand_on_the_tick_it_died_and_read_zero_after()
{
- var p = new Physiology(Body3(), Plan3(blood: new BloodDef(1000.0, 0.5, 1e-4), slots: 9, organism: new[] { Hypoxia }), 20);
- Assert.True(p.Afflict(Af("Bleeder"), 1, 0, 0.8));
+ var airway = InertAirway with { CoughByConsciousness = new[] { (0.0, 1.0), (1.0, 1.0) } }; // a cough that does not need consciousness, so it still runs on the step the brain lesion kills
+ var p = Bleeding(0.5, 1.0, airway, new BloodDef(1000.0, 0.5, 1e-4)); // bleeds into the airway, which coughs and drains; the blood is too deep to run out
var a = Make(p);
var s = new float[2];
var q = new Quat[2];
- for (var i = 0; i < 10; i++) Assert.Equal(TickEvents.None, Tick(a, 0.0, s, q) & TickEvents.Died);
- Assert.True(p.Bleed(1) > 0.0);
+ var box = new[] { new BoxStimulus(0f, 0f, 0f, 1f, 1f, 1f) { Intensity = 0.0 } };
+ var air = new AirwaySample(1e-6, 1e-6, airway.DrainDrop);
+ for (var i = 0; i < 10; i++) Assert.Equal(TickEvents.None, a.Tick(NoPoint, NoPoint, NoPoint, box, s, q, airway: air) & TickEvents.Died);
+ Assert.True(p.Bleed(0) > 0.0 && p.AirwayBleed > 0.0 && p.DrawnLive > 0.0 && p.DrawnPooled > 0.0 && p.Coughed > 0.0 && p.Drained > 0.0);
Assert.True(p.Afflict(Af("Lesion"), 0, BrainLayer, 10)); // not the heart: a stopped heart would stop the bleed on the dying step
- Assert.Equal(TickEvents.Died, Tick(a, 0.0, s, q));
+ Assert.Equal(TickEvents.Died, a.Tick(NoPoint, NoPoint, NoPoint, box, s, q, airway: air));
Assert.True(p.Dead);
- Assert.True(p.Bleed(1) > 0.0, "the dying step's bleed was not reported"); // Lodur reports the step it died on
- Assert.Equal(TickEvents.None, Tick(a, 0.0, s, q));
- Assert.Equal(0.0, p.Bleed(1));
+ Assert.True(p.Bleed(0) > 0.0, "the dying step's bleed was not reported"); // Lodur reports the step it died on
+ Assert.True(p.AirwayBleed > 0.0 && p.DrawnLive > 0.0 && p.DrawnPooled > 0.0 && p.Coughed > 0.0 && p.Drained > 0.0, "a flow of the dying step was not reported");
+ Assert.Equal(TickEvents.None, a.Tick(NoPoint, NoPoint, NoPoint, box, s, q, airway: air));
+ Assert.Equal(0.0, p.Bleed(0));
Assert.Equal(0.0, p.AirwayBleed);
Assert.Equal(0.0, p.DrawnLive);
Assert.Equal(0.0, p.DrawnPooled);
@@ -234,7 +237,7 @@ public sealed class ActorPhysiologyTests
}
}
- /// The measuring loop lives here, fully optimised from its first call, so tiered compilation and TieredPGO instrumentation cannot allocate inside the measurement; only Actor.Tick's own bytes are counted.
+ /// The measuring loop lives here, fully optimised from its first call, so the tier-up and its first-tier instrumentation cannot allocate inside the measurement; only Actor.Tick's own bytes are counted.
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.NoInlining | System.Runtime.CompilerServices.MethodImplOptions.AggressiveOptimization)]
private static long AllocatedByTicking(Actor a, BoxStimulus[] box, float[] s, Quat[] q, int n)
{
diff --git a/tests/Lodur.Core.Tests/AirwayBleedTests.cs b/tests/Lodur.Core.Tests/AirwayBleedTests.cs
index c83cc48..ee67c66 100644
--- a/tests/Lodur.Core.Tests/AirwayBleedTests.cs
+++ b/tests/Lodur.Core.Tests/AirwayBleedTests.cs
@@ -13,24 +13,8 @@ public sealed class AirwayBleedTests
private const double Dt = 0.01;
private const double Rate = 1e-3;
- /// A cough-free, drain-free airway with a breath that draws the liquid at the openings and holds at 1e-3 of it.
- private static AirwayDef Quiet => new(150e-6, 1.0, 1.0, 1.0, 1e-3, 0.0, new[] { (0.0, 0.0), (1.0, 0.0) }, 0.0, 0.05);
-
private static void Near(double expected, double actual) => Assert.InRange(Math.Abs(expected - actual), 0.0, 1e-12 * Math.Abs(expected));
- private static Physiology Bleeding(double share, double gain, AirwayDef? airway = null, BloodDef? blood = null)
- {
- var root = new[]
- {
- new TissueDef("brain", 10, 1, Consciousness: 1),
- new TissueDef("heart", 10, 4, true, BloodPumping: 1),
- new TissueDef("muscle", 10, 1, Motor: 1) { AirwayShare = share },
- };
- var p = new Physiology(Body3(), Plan3(root: root, airway: airway ?? Quiet, blood: blood), 20.0, gain);
- Assert.True(p.Afflict(Af("Bleeder"), 0, RootMuscle, 1));
- return p;
- }
-
[Theory]
[InlineData(0.25)]
[InlineData(0.0)]
diff --git a/tests/Lodur.Core.Tests/PhysiologyFixtures.cs b/tests/Lodur.Core.Tests/PhysiologyFixtures.cs
index d0731a1..6ce80d6 100644
--- a/tests/Lodur.Core.Tests/PhysiologyFixtures.cs
+++ b/tests/Lodur.Core.Tests/PhysiologyFixtures.cs
@@ -53,6 +53,22 @@ internal static class PhysioFixtures
/// No liquid ever counts as at the airway: the airway stays empty and the hold is never wanted.
public static AirwayDef InertAirway => new(150e-6, 1.0, 1.0, 1.0, 1e9, 2.0, new[] { (0.3, 0.0), (0.6, 1.0) }, 0.1, 0.05);
+ /// A cough-free, drain-free airway with a breath that draws the liquid at the openings and holds at 1e-3 of it.
+ public static AirwayDef Quiet => new(150e-6, 1.0, 1.0, 1.0, 1e-3, 0.0, new[] { (0.0, 0.0), (1.0, 0.0) }, 0.0, 0.05);
+
+ public static Physiology Bleeding(double share, double gain, AirwayDef? airway = null, BloodDef? blood = null)
+ {
+ var root = new[]
+ {
+ new TissueDef("brain", 10, 1, Consciousness: 1),
+ new TissueDef("heart", 10, 4, true, BloodPumping: 1),
+ new TissueDef("muscle", 10, 1, Motor: 1) { AirwayShare = share },
+ };
+ var p = new Physiology(Body3(), Plan3(root: root, airway: airway ?? Quiet, blood: blood), 20.0, gain);
+ Assert.True(p.Afflict(Af("Bleeder"), 0, RootMuscle, 1));
+ return p;
+ }
+
/// The humanoid's hypoxia curve: brain oxygen to consciousness, flat 1 above 0.70.
public static Effect Hypoxia => new(EffectTarget.Consciousness, EffectOp.Factor, EffectDriver.BrainOxygen, new[] { (0.10, 0.0), (0.35, 0.1), (0.70, 1.0) });