Implement more tests for instance methods

This commit is contained in:
Filip Tibell 2023-03-25 17:26:16 +01:00
parent c43d164c6a
commit 191bbf15bb
No known key found for this signature in database
4 changed files with 104 additions and 0 deletions

View file

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

View file

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

View file

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

View file

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