Attempt to fix tests (reimplement get_children)

This commit is contained in:
Olari Tšernobrovkin 2026-07-07 18:27:10 +03:00
parent 0d8abd884d
commit 3ce99b2c6e
No known key found for this signature in database
GPG key ID: 3CC0189D1D6A3A22
2 changed files with 10 additions and 1 deletions

View file

@ -279,6 +279,14 @@ local function create_source_node<T>(value: T): SourceNode<T>
return { cache = value, children = {} }
end
local function get_children_as_array<T>(node: Node<T>): { Node<unknown> }
local arr = {}
for child, _ in node.children do
table.insert(arr, child)
end
return arr
end
local function set_context<T>(node: Node<T>, key: number, value: unknown)
if node.context then
node.context[key] = value
@ -301,6 +309,7 @@ return table.freeze {
push_child = push_child,
create_node = create_node,
create_source_node = create_source_node,
get_children_as_array = get_children_as_array,
flush_update_queue = flush_update_queue,
get_update_queue_length = get_update_queue_length,
set_context = set_context,

View file

@ -61,7 +61,7 @@ TEST("graph", function()
local get_scope = graph.get_scope
local push_scope = graph.push_scope
local pop_scope = graph.pop_scope
local get_children = graph.get_children
local get_children = graph.get_children_as_array
local push_cleanup = graph.push_cleanup
local destroy = graph.destroy