Finish up roblox instance method test suite

This commit is contained in:
Filip Tibell 2023-03-25 18:04:19 +01:00
parent e9bea839b3
commit dcec0e6ad3
No known key found for this signature in database
8 changed files with 149 additions and 0 deletions

View file

@ -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",
} }

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)

View 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)