Fix springs not finishing when moving to zero (#98)

This commit is contained in:
Kaan 2026-10-19 14:05:23 +03:00 • committed by GitHub
parent b010497a01
commit 86dee3c87c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 2 deletions

View file

@ -2121,6 +2121,32 @@ TEST("spring()", wrap_root(function()
CHECK(count == 1) -- check spring was rescheduled correctly
end
do CASE "spring finished at zero"
local input = source(1)
local output, control = spring(input)
local count = 0
effect(function()
output()
count += 1
end)
input(0)
step(10)
CHECK(output() == 0)
count = 0
step(1)
CHECK(count == 0) -- check spring is finished
control { impulse = 1 }
step(10)
count = 0
step(1)
CHECK(count == 0) -- check spring is finished after impulse at rest
end
do CASE "spring control"
local input = source(1)
local output, control = spring(input)