mirror of
https://github.com/centau/vide.git
synced 2026-08-20 23:01:37 +00:00
This commit is contained in:
parent
795ff8725c
commit
5057b7772b
2 changed files with 42 additions and 2 deletions
|
|
@ -1016,6 +1016,7 @@ TEST("spring()", function()
|
|||
local create = vide.create
|
||||
local source = vide.source
|
||||
local spring = vide.spring
|
||||
local watch = vide.watch
|
||||
|
||||
do CASE "Update state (on next hearbeat resumption cycle)"
|
||||
local value = source(10)
|
||||
|
|
@ -1067,6 +1068,30 @@ TEST("spring()", function()
|
|||
gc()
|
||||
CHECK(wref[1]) -- `output` should not gc
|
||||
end
|
||||
|
||||
do CASE "Spring finished"
|
||||
local input = source(0)
|
||||
local output = spring(input)
|
||||
|
||||
input(1)
|
||||
vide.step(1e9) -- spring alpha at ~1
|
||||
|
||||
local count = -1
|
||||
watch(function()
|
||||
output()
|
||||
count += 1
|
||||
end)
|
||||
|
||||
vide.step(1) -- spring should be internally removed from spring queue
|
||||
CHECK(count == 0)
|
||||
|
||||
--
|
||||
|
||||
gc() -- perform full gc
|
||||
input(2) -- spring should be re-added to spring queue
|
||||
vide.step(0) -- process spring queue
|
||||
CHECK(count == 1) -- check spring was rescheduled correctly
|
||||
end
|
||||
end)
|
||||
|
||||
TEST("Events", function()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue