mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
This commit is contained in:
parent
4f9db6ff41
commit
3ecec1f787
2 changed files with 65 additions and 21 deletions
|
|
@ -103,7 +103,7 @@ TEST("graph", function()
|
|||
CHECK(count == 3)
|
||||
end
|
||||
|
||||
do CASE "diamond problem"
|
||||
do CASE "diamond graph"
|
||||
local a, b, c, d = node(), node(), node(), node()
|
||||
|
||||
local b_cnt, c_cnt, d_cnt = 0, 0, 0
|
||||
|
|
@ -119,7 +119,7 @@ TEST("graph", function()
|
|||
|
||||
CHECK(b_cnt == 1)
|
||||
CHECK(c_cnt == 1)
|
||||
CHECK(d_cnt == 2) -- confirm current behavior
|
||||
CHECK(d_cnt == 1)
|
||||
end
|
||||
|
||||
do CASE "duplicate child on rerun"
|
||||
|
|
@ -387,6 +387,36 @@ TEST("derive()", wrap_root(function()
|
|||
CHECK(count == 4)
|
||||
end
|
||||
|
||||
do CASE "conditional derive"
|
||||
local a = source(false)
|
||||
local b = source(false)
|
||||
|
||||
local c = derive(function()
|
||||
return
|
||||
if a() then "a"
|
||||
elseif b() then "b"
|
||||
else "never"
|
||||
end)
|
||||
|
||||
local count = 0
|
||||
|
||||
watch(function() count += 1 end)
|
||||
|
||||
b(true)
|
||||
CHECK(c() == "b")
|
||||
CHECK(count == 2)
|
||||
a(true)
|
||||
CHECK(c() == "a")
|
||||
CHECK(count == 3)
|
||||
b(false)
|
||||
CHECK(count == 3)
|
||||
b(true)
|
||||
CHECK(count == 3)
|
||||
a(false)
|
||||
CHECK(c() == "b")
|
||||
CHECK(count == 4)
|
||||
end
|
||||
|
||||
do CASE "garbage collection"
|
||||
-- check that `b` does not allow gc of `a`
|
||||
local a = source(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue