mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Finish up roblox instance method test suite
This commit is contained in:
parent
e9bea839b3
commit
dcec0e6ad3
8 changed files with 149 additions and 0 deletions
|
@ -123,4 +123,20 @@ create_tests! {
|
||||||
roblox_instance_attributes: "roblox/instance/attributes",
|
roblox_instance_attributes: "roblox/instance/attributes",
|
||||||
roblox_instance_new: "roblox/instance/new",
|
roblox_instance_new: "roblox/instance/new",
|
||||||
roblox_instance_properties: "roblox/instance/properties",
|
roblox_instance_properties: "roblox/instance/properties",
|
||||||
|
roblox_instance_methods_clear_all_children: "roblox/instance/methods/ClearAllChildren",
|
||||||
|
roblox_instance_methods_clone: "roblox/instance/methods/Clone",
|
||||||
|
roblox_instance_methods_destroy: "roblox/instance/methods/Destroy",
|
||||||
|
roblox_instance_methods_find_first_ancestor: "roblox/instance/methods/FindFirstAncestor",
|
||||||
|
roblox_instance_methods_find_first_ancestor_of_class: "roblox/instance/methods/FindFirstAncestorOfClass",
|
||||||
|
roblox_instance_methods_find_first_ancestor_which_is_a: "roblox/instance/methods/FindFirstAncestorWhichIsA",
|
||||||
|
roblox_instance_methods_find_first_child: "roblox/instance/methods/FindFirstChild",
|
||||||
|
roblox_instance_methods_find_first_child_of_class: "roblox/instance/methods/FindFirstChildOfClass",
|
||||||
|
roblox_instance_methods_find_first_child_which_is_a: "roblox/instance/methods/FindFirstChildWhichIsA",
|
||||||
|
roblox_instance_methods_find_first_descendant: "roblox/instance/methods/FindFirstDescendant",
|
||||||
|
roblox_instance_methods_get_children: "roblox/instance/methods/GetChildren",
|
||||||
|
roblox_instance_methods_get_descendants: "roblox/instance/methods/GetDescendants",
|
||||||
|
roblox_instance_methods_get_full_name: "roblox/instance/methods/GetFullName",
|
||||||
|
roblox_instance_methods_is_a: "roblox/instance/methods/IsA",
|
||||||
|
roblox_instance_methods_is_ancestor_of: "roblox/instance/methods/IsAncestorOf",
|
||||||
|
roblox_instance_methods_is_descendant_of: "roblox/instance/methods/IsDescendantOf",
|
||||||
}
|
}
|
||||||
|
|
16
tests/roblox/instance/methods/FindFirstAncestor.luau
Normal file
16
tests/roblox/instance/methods/FindFirstAncestor.luau
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
local roblox = require("@lune/roblox") :: any
|
||||||
|
local Instance = roblox.Instance
|
||||||
|
|
||||||
|
local root = Instance.new("Folder")
|
||||||
|
local child = Instance.new("Model")
|
||||||
|
local nested = Instance.new("Tool")
|
||||||
|
local descendant = Instance.new("Part")
|
||||||
|
|
||||||
|
descendant.Parent = nested
|
||||||
|
nested.Parent = child
|
||||||
|
child.Parent = root
|
||||||
|
|
||||||
|
assert(descendant:FindFirstAncestor("Part") == nil)
|
||||||
|
assert(descendant:FindFirstAncestor("Tool") == nested)
|
||||||
|
assert(descendant:FindFirstAncestor("Model") == child)
|
||||||
|
assert(descendant:FindFirstAncestor("Folder") == root)
|
16
tests/roblox/instance/methods/FindFirstAncestorOfClass.luau
Normal file
16
tests/roblox/instance/methods/FindFirstAncestorOfClass.luau
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
local roblox = require("@lune/roblox") :: any
|
||||||
|
local Instance = roblox.Instance
|
||||||
|
|
||||||
|
local root = Instance.new("Folder")
|
||||||
|
local child = Instance.new("Model")
|
||||||
|
local nested = Instance.new("Tool")
|
||||||
|
local descendant = Instance.new("Part")
|
||||||
|
|
||||||
|
descendant.Parent = nested
|
||||||
|
nested.Parent = child
|
||||||
|
child.Parent = root
|
||||||
|
|
||||||
|
assert(descendant:FindFirstAncestorOfClass("Part") == nil)
|
||||||
|
assert(descendant:FindFirstAncestorOfClass("Tool") == nested)
|
||||||
|
assert(descendant:FindFirstAncestorOfClass("Model") == child)
|
||||||
|
assert(descendant:FindFirstAncestorOfClass("Folder") == root)
|
16
tests/roblox/instance/methods/FindFirstAncestorWhichIsA.luau
Normal file
16
tests/roblox/instance/methods/FindFirstAncestorWhichIsA.luau
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
local roblox = require("@lune/roblox") :: any
|
||||||
|
local Instance = roblox.Instance
|
||||||
|
|
||||||
|
local root = Instance.new("Folder")
|
||||||
|
local child = Instance.new("Model")
|
||||||
|
local nested = Instance.new("Tool")
|
||||||
|
local descendant = Instance.new("Part")
|
||||||
|
|
||||||
|
descendant.Parent = nested
|
||||||
|
nested.Parent = child
|
||||||
|
child.Parent = root
|
||||||
|
|
||||||
|
assert(descendant:FindFirstAncestorWhichIsA("Part") == nil)
|
||||||
|
assert(descendant:FindFirstAncestorWhichIsA("Tool") == nested)
|
||||||
|
assert(descendant:FindFirstAncestorWhichIsA("Model") == nested)
|
||||||
|
assert(descendant:FindFirstAncestorWhichIsA("Folder") == root)
|
18
tests/roblox/instance/methods/FindFirstChild.luau
Normal file
18
tests/roblox/instance/methods/FindFirstChild.luau
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
local roblox = require("@lune/roblox") :: any
|
||||||
|
local Instance = roblox.Instance
|
||||||
|
|
||||||
|
local root = Instance.new("Folder")
|
||||||
|
local child = Instance.new("Model")
|
||||||
|
local nested = Instance.new("Tool")
|
||||||
|
local adjacent = Instance.new("Model")
|
||||||
|
local descendant = Instance.new("Part")
|
||||||
|
|
||||||
|
descendant.Parent = nested
|
||||||
|
nested.Parent = child
|
||||||
|
adjacent.Parent = child
|
||||||
|
child.Parent = root
|
||||||
|
|
||||||
|
assert(child:FindFirstChild("Folder") == nil)
|
||||||
|
assert(child:FindFirstChild("Model") == adjacent)
|
||||||
|
assert(child:FindFirstChild("Tool") == nested)
|
||||||
|
assert(child:FindFirstChild("Part") == nil)
|
18
tests/roblox/instance/methods/FindFirstChildOfClass.luau
Normal file
18
tests/roblox/instance/methods/FindFirstChildOfClass.luau
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
local roblox = require("@lune/roblox") :: any
|
||||||
|
local Instance = roblox.Instance
|
||||||
|
|
||||||
|
local root = Instance.new("Folder")
|
||||||
|
local child = Instance.new("Model")
|
||||||
|
local nested = Instance.new("Tool")
|
||||||
|
local adjacent = Instance.new("Model")
|
||||||
|
local descendant = Instance.new("Part")
|
||||||
|
|
||||||
|
descendant.Parent = nested
|
||||||
|
nested.Parent = child
|
||||||
|
adjacent.Parent = child
|
||||||
|
child.Parent = root
|
||||||
|
|
||||||
|
assert(child:FindFirstChildOfClass("Folder") == nil)
|
||||||
|
assert(child:FindFirstChildOfClass("Tool") == nested)
|
||||||
|
assert(child:FindFirstChildOfClass("Model") == adjacent)
|
||||||
|
assert(child:FindFirstChildOfClass("Part") == nil)
|
18
tests/roblox/instance/methods/FindFirstChildWhichIsA.luau
Normal file
18
tests/roblox/instance/methods/FindFirstChildWhichIsA.luau
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
local roblox = require("@lune/roblox") :: any
|
||||||
|
local Instance = roblox.Instance
|
||||||
|
|
||||||
|
local root = Instance.new("Folder")
|
||||||
|
local child = Instance.new("Model")
|
||||||
|
local nested = Instance.new("Tool")
|
||||||
|
local adjacent = Instance.new("Model")
|
||||||
|
local descendant = Instance.new("Part")
|
||||||
|
|
||||||
|
descendant.Parent = nested
|
||||||
|
nested.Parent = child
|
||||||
|
adjacent.Parent = child
|
||||||
|
child.Parent = root
|
||||||
|
|
||||||
|
assert(child:FindFirstChildWhichIsA("Folder") == nil)
|
||||||
|
assert(child:FindFirstChildWhichIsA("Tool") == nested)
|
||||||
|
assert(child:FindFirstChildWhichIsA("Model") == nested)
|
||||||
|
assert(child:FindFirstChildWhichIsA("Part") == nil)
|
31
tests/roblox/instance/methods/FindFirstDescendant.luau
Normal file
31
tests/roblox/instance/methods/FindFirstDescendant.luau
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
local roblox = require("@lune/roblox") :: any
|
||||||
|
local Instance = roblox.Instance
|
||||||
|
|
||||||
|
local root = Instance.new("Folder")
|
||||||
|
local inner1 = Instance.new("Model")
|
||||||
|
local inner1_1 = Instance.new("Part")
|
||||||
|
local inner1_2 = Instance.new("Part")
|
||||||
|
local inner2 = Instance.new("Model")
|
||||||
|
local inner2_1 = Instance.new("Part")
|
||||||
|
local inner2_2 = Instance.new("Part")
|
||||||
|
|
||||||
|
inner1.Parent = root
|
||||||
|
inner1_1.Parent = inner1
|
||||||
|
inner1_2.Parent = inner1
|
||||||
|
inner2.Parent = root
|
||||||
|
inner2_1.Parent = inner2
|
||||||
|
inner2_2.Parent = inner2
|
||||||
|
|
||||||
|
assert(root:FindFirstDescendant("Folder") == nil)
|
||||||
|
assert(root:FindFirstDescendant("Model") == inner1)
|
||||||
|
assert(root:FindFirstDescendant("Part") == inner1_1)
|
||||||
|
|
||||||
|
inner1:Destroy()
|
||||||
|
|
||||||
|
assert(root:FindFirstDescendant("Folder") == nil)
|
||||||
|
assert(root:FindFirstDescendant("Model") == inner2)
|
||||||
|
assert(root:FindFirstDescendant("Part") == inner2_1)
|
||||||
|
|
||||||
|
inner2_1:Destroy()
|
||||||
|
|
||||||
|
assert(root:FindFirstDescendant("Part") == inner2_2)
|
Loading…
Reference in a new issue