Update spring tests

This commit is contained in:
aaron 2023-08-26 14:49:46 +01:00
parent ffef8e24ca
commit 5ab76a434e
3 changed files with 71 additions and 19 deletions

View file

@ -214,6 +214,19 @@ TEST("source()", function()
state(b)
CHECK(updates == 1)
end
do CASE "garbage collection of node"
local capture = require "src/graph".capture
local src = source(0)
local wref do
local node = unpack(capture(src))
wref = weak { node }
end
gc()
CHECK(not wref[1])
end
end)
TEST("derive()", function()
@ -332,6 +345,20 @@ TEST("derive()", function()
CHECK(c() == 2)
end
end
do CASE "garbage collection of node"
local capture = require "src/graph".capture
local input = source(1)
local wref do
local output = derive(input)
local output_node = unpack(capture(output))
wref = weak { output_node }
end
gc()
CHECK(not wref[1])
end
end)
TEST("watch()", function()
@ -632,8 +659,6 @@ TEST("create()", function()
Position = UDim2.new()
}
print("template", template.AnchorPoint)
local text = create(template) {
AnchorPoint = { 1, 2 },
Position = { 3, 4 }
@ -1215,8 +1240,24 @@ TEST("spring()", function()
gc()
CHECK(not wref[1])
end
end
do -- spring data gc
local capture = require "src/graph".capture
local input = source(10)
local wref do
local output, data = (spring :: any)(input)
input(input() + 1) -- schedule spring calculation
local output_node = unpack(capture(output))
wref = weak { output_node, data }
end
gc()
CHECK(not wref[1])
CHECK(not wref[2])
end
end
do CASE "garbage collection (binded)"
local input = source(10)