diff --git a/tests/roblox/instance/methods/Destroy.luau b/tests/roblox/instance/methods/Destroy.luau new file mode 100644 index 0000000..113fead --- /dev/null +++ b/tests/roblox/instance/methods/Destroy.luau @@ -0,0 +1,35 @@ +local roblox = require("@lune/roblox") :: any +local Instance = roblox.Instance + +local root = Instance.new("Folder") +local child = Instance.new("Model") +local descendant = Instance.new("Part") + +child.Parent = root +descendant.Parent = child + +root:Destroy() + +assert(not pcall(function() + return root.Name +end)) + +assert(not pcall(function() + return root.Parent +end)) + +assert(not pcall(function() + return child.Name +end)) + +assert(not pcall(function() + return child.Parent +end)) + +assert(not pcall(function() + return descendant.Name +end)) + +assert(not pcall(function() + return descendant.Parent +end)) diff --git a/tests/roblox/instance/methods/IsA.luau b/tests/roblox/instance/methods/IsA.luau new file mode 100644 index 0000000..1732af4 --- /dev/null +++ b/tests/roblox/instance/methods/IsA.luau @@ -0,0 +1,27 @@ +local roblox = require("@lune/roblox") :: any +local Instance = roblox.Instance + +local part = Instance.new("Part") +local workspace = Instance.new("Workspace") + +-- Valid + +assert(part:IsA("Part") == true) +assert(part:IsA("BasePart") == true) +assert(part:IsA("PVInstance") == true) +assert(part:IsA("Instance") == true) + +assert(workspace:IsA("Workspace") == true) +assert(workspace:IsA("Model") == true) +assert(workspace:IsA("Instance") == true) + +-- Invalid + +assert(part:IsA("part") == false) +assert(part:IsA("Base-Part") == false) +assert(part:IsA("Model") == false) +assert(part:IsA("Paart") == false) + +assert(workspace:IsA("Service") == false) +assert(workspace:IsA(".") == false) +assert(workspace:IsA("") == false) diff --git a/tests/roblox/instance/methods/IsAncestorOf.luau b/tests/roblox/instance/methods/IsAncestorOf.luau new file mode 100644 index 0000000..a482c97 --- /dev/null +++ b/tests/roblox/instance/methods/IsAncestorOf.luau @@ -0,0 +1,21 @@ +local roblox = require("@lune/roblox") :: any +local Instance = roblox.Instance + +local root = Instance.new("Folder") +local child = Instance.new("Model") +local descendant = Instance.new("Part") + +child.Parent = root +descendant.Parent = child + +assert(not root:IsAncestorOf(root)) +assert(not child:IsAncestorOf(root)) +assert(not descendant:IsAncestorOf(root)) + +assert(root:IsAncestorOf(child)) +assert(not child:IsAncestorOf(child)) +assert(not descendant:IsAncestorOf(child)) + +assert(root:IsAncestorOf(descendant)) +assert(child:IsAncestorOf(descendant)) +assert(not descendant:IsAncestorOf(descendant)) diff --git a/tests/roblox/instance/methods/IsDescendantOf.luau b/tests/roblox/instance/methods/IsDescendantOf.luau new file mode 100644 index 0000000..8a65c64 --- /dev/null +++ b/tests/roblox/instance/methods/IsDescendantOf.luau @@ -0,0 +1,21 @@ +local roblox = require("@lune/roblox") :: any +local Instance = roblox.Instance + +local root = Instance.new("Folder") +local child = Instance.new("Model") +local descendant = Instance.new("Part") + +child.Parent = root +descendant.Parent = child + +assert(not root:IsDescendantOf(root)) +assert(child:IsDescendantOf(root)) +assert(descendant:IsDescendantOf(root)) + +assert(not root:IsDescendantOf(child)) +assert(not child:IsDescendantOf(child)) +assert(descendant:IsDescendantOf(child)) + +assert(not root:IsDescendantOf(descendant)) +assert(not child:IsDescendantOf(descendant)) +assert(not descendant:IsDescendantOf(descendant))