simplified test case and remove error

This commit is contained in:
alice 2024-08-15 02:52:46 +02:00 committed by centau
parent d341eff5c8
commit a44fa339d5
3 changed files with 8 additions and 23 deletions

View file

@ -16,8 +16,8 @@ local function batch(setter: () -> ())
local ok, err: string? = pcall(setter) local ok, err: string? = pcall(setter)
if not already_batching then if not already_batching then
flush()
flags.batch = false flags.batch = false
flush()
end end
if not ok then throw(`error occured while batching updates: {err}`) end if not ok then throw(`error occured while batching updates: {err}`) end

View file

@ -184,13 +184,10 @@ local function queue_children_for_update<T>(node: SourceNode<T>)
update_queue.n = i update_queue.n = i
end end
local _flushing = false
local function flush_update_queue() local function flush_update_queue()
local n0 = update_queue.n local n0 = update_queue.n
return function() return function()
assert(not _flushing, "recursive queue flush occured") -- todo
_flushing = true
local i = n0 + 1 local i = n0 + 1
while i <= update_queue.n do while i <= update_queue.n do
@ -207,7 +204,6 @@ local function flush_update_queue()
update_queue.n = n0 update_queue.n = n0
_flushing = false
end end
end end

View file

@ -1924,28 +1924,17 @@ TEST("batch()", wrap_root(function()
do CASE "recursive queue flush" do CASE "recursive queue flush"
local a0 = source(0) local a0 = source(0)
local a1 = source(1) local a1 = source(0)
local a2 = source(0)
local updates = 0 local updates = 0
derive(function() derive(function() -- depends on a1
a0(a1() + 1) a0(a1())
end) end)
derive(function() derive(function() -- batch updates a2
updates += 1 updates += 1
a0() a0()
batch(function()
a2(a0())
end)
return 1
end)
derive(function()
a2()
batch(function() batch(function()
end) end)
@ -1953,7 +1942,7 @@ TEST("batch()", wrap_root(function()
return 1 return 1
end) end)
a1(2) a1(1)
CHECK(updates == 2) CHECK(updates == 2)
end end
end)) end))