This commit is contained in:
aaron 2023-08-07 13:12:36 +01:00
parent 6f9e86c5c7
commit d0fc816460
4 changed files with 34 additions and 25 deletions

View file

@ -131,11 +131,11 @@ BENCH("indexes() no change", function()
local state = vide.source(data)
local _list = vide.values(state, function(v, i)
local _list = vide.indexes(state, function(v, i)
return {}
end)
state(state()) -- fill double buffer
--state(state()) -- fill double buffer
START(N)
@ -152,11 +152,11 @@ BENCH("indexes() all change", function()
local state = vide.source(data)
local _list = vide.values(state, function(v, i)
local _list = vide.indexes(state, function(v, i)
return {}
end)
state(state()) -- fill double buffer
--state(state()) -- fill double buffer
for i, v in data do
data[i] = v + 1
@ -176,7 +176,7 @@ BENCH("indexes() all remove", function()
local state = vide.source(data)
local _list = vide.values(state, function(v, i)
local _list = vide.indexes(state, function(v, i)
return {}
end)

View file

@ -1147,7 +1147,10 @@ TEST("spring()", function()
local output = spring(input)
input(1)
vide.step(1e9) -- spring alpha at ~1
vide.step(0.05)
CHECK(output() ~= input()) -- check spring is moving
vide.step(6) -- spring finished, should be internally removed from queue
CHECK(output() == input()) -- check spring is at target
local count = -1
watch(function()
@ -1155,15 +1158,14 @@ TEST("spring()", function()
count += 1
end)
vide.step(1) -- spring should be internally removed from spring queue
CHECK(count == 0)
vide.step(1) -- attempt to cause another spring update
CHECK(count == 1) -- check no update occurs as spring is finished
--
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
CHECK(count == 2) -- check spring was rescheduled correctly
end
end)