mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Add repeated read test
This commit is contained in:
parent
8218e4702f
commit
15255855c3
2 changed files with 8 additions and 39 deletions
|
|
@ -181,44 +181,6 @@ local function evaluate_node<T>(node: Node<T>)
|
|||
return cur_value ~= new_value -- node has changed value
|
||||
end
|
||||
|
||||
-- local function update_from<T>(node: StartNode<T>, n0: number)
|
||||
-- if not node[1] then return end
|
||||
|
||||
-- local n = n0
|
||||
|
||||
-- -- unparent all children and queue for eval
|
||||
-- do
|
||||
-- local child = node[1]
|
||||
-- while child do
|
||||
-- --assert(child.parents.owner)
|
||||
-- unparent(child)
|
||||
-- n += 1
|
||||
-- update_queue[n] = child
|
||||
-- child = node[1]
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- update_queue.n = n
|
||||
|
||||
-- -- evaluate all queued children
|
||||
-- for i = n0 + 1, n do
|
||||
-- local child = update_queue[i]
|
||||
-- assert(type(child.effect) == "function")
|
||||
|
||||
-- if evaluate_node(child) then
|
||||
-- update_from(child, n)
|
||||
-- end
|
||||
|
||||
-- update_queue[i] = false :: any -- false instead of nil to avoid sparse
|
||||
-- end
|
||||
|
||||
-- update_queue.n = n0
|
||||
-- end
|
||||
|
||||
-- local function update<T>(node: StartNode<T>)
|
||||
-- update_from(node, update_queue.n)
|
||||
-- end
|
||||
|
||||
local function queue_children<T>(node: StartNode<T>)
|
||||
local i = update_queue.n
|
||||
local child = node[1]
|
||||
|
|
|
|||
|
|
@ -1969,7 +1969,6 @@ TEST("graph edge cases", wrap_root(function()
|
|||
|
||||
a(1)
|
||||
|
||||
print(e())
|
||||
CHECK(count.b == 2)
|
||||
CHECK(count.c == 2)
|
||||
CHECK(count.d == 2)
|
||||
|
|
@ -1985,7 +1984,15 @@ TEST("graph edge cases", wrap_root(function()
|
|||
end
|
||||
|
||||
do CASE "repeated read"
|
||||
local a = source(0)
|
||||
local b = derive(function() return a() + a() end)
|
||||
|
||||
local count = 0
|
||||
effect(function() b(); count += 1 end)
|
||||
|
||||
a(1)
|
||||
CHECK(b() == 2)
|
||||
CHECK(count == 2)
|
||||
end
|
||||
end))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue