mirror of
https://github.com/centau/vide.git
synced 2026-08-20 14:41:37 +00:00
Update spring tests
This commit is contained in:
parent
ffef8e24ca
commit
5ab76a434e
3 changed files with 71 additions and 19 deletions
|
|
@ -13,10 +13,6 @@ local function step(): number
|
|||
end
|
||||
|
||||
local function main()
|
||||
local source = vide.source
|
||||
local spring = vide.spring
|
||||
local watch = vide.watch
|
||||
|
||||
local TERMINAL_HEIGHT = 73 --* REDUCE IF BAR DOES NOT FIT IN TERMINAL
|
||||
local MIN_ALPHA = 0.3
|
||||
local MAX_ALPHA = 0.7
|
||||
|
|
@ -39,6 +35,10 @@ local function main()
|
|||
else "▁"
|
||||
end
|
||||
|
||||
local source = vide.source
|
||||
local spring = vide.spring
|
||||
local watch = vide.watch
|
||||
|
||||
local value = source(MAX)
|
||||
local sprung = spring(value, 1, 0.3)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue