Implement more instance method tests

This commit is contained in:
Filip Tibell 2023-03-25 17:07:08 +01:00
parent 6895b66550
commit c43d164c6a
No known key found for this signature in database
5 changed files with 50 additions and 2 deletions

View file

@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed accessing a destroyed instance printing an error message even if placed inside a pcall
- Fixed cloned instances not having correct instance reference properties set (`ObjectValue.Value`, `Motor6D.Part0`, ...)
- Fixed `Instance::GetDescendants` returning the same thing as `Instance::GetChildren` (oops)
## `0.6.2` - March 25th, 2023

View file

@ -538,7 +538,7 @@ impl Instance {
descendants.push(*queue_ref);
let queue_inst = dom.get_by_ref(*queue_ref).unwrap();
for queue_ref_inner in queue_inst.children().iter().rev() {
queue.push_front(queue_ref_inner);
queue.push_back(queue_ref_inner);
}
}
@ -902,7 +902,7 @@ impl LuaUserData for Instance {
});
methods.add_method("GetDescendants", |lua, this, ()| {
this.ensure_not_destroyed()?;
this.get_children().to_lua(lua)
this.get_descendants().to_lua(lua)
});
methods.add_method("GetFullName", |lua, this, ()| {
this.ensure_not_destroyed()?;

View file

@ -0,0 +1,18 @@
local roblox = require("@lune/roblox") :: any
local Instance = roblox.Instance
local model =
roblox.readModelFile("tests/roblox/rbx-test-files/models/three-nested-folders/binary.rbxm")[1]
assert(#model:GetChildren() == 1)
local newChild = Instance.new("Model")
newChild.Parent = model
assert(#model:GetChildren() == 2)
assert(table.find(model:GetChildren(), newChild) ~= nil)
newChild:Destroy()
assert(#model:GetChildren() == 1)
assert(table.find(model:GetChildren(), newChild) == nil)

View file

@ -0,0 +1,18 @@
local roblox = require("@lune/roblox") :: any
local Instance = roblox.Instance
local model =
roblox.readModelFile("tests/roblox/rbx-test-files/models/three-nested-folders/binary.rbxm")[1]
assert(#model:GetDescendants() == 2)
local newChild = Instance.new("Model")
newChild.Parent = model
assert(#model:GetDescendants() == 3)
assert(table.find(model:GetDescendants(), newChild) == 2)
newChild:Destroy()
assert(#model:GetDescendants() == 2)
assert(table.find(model:GetDescendants(), newChild) == nil)

View file

@ -0,0 +1,11 @@
local roblox = require("@lune/roblox") :: any
local model =
roblox.readModelFile("tests/roblox/rbx-test-files/models/three-nested-folders/binary.rbxm")[1]
local child = model:FindFirstChild("Parent")
local descendant = child:FindFirstChild("Child")
assert(descendant:GetFullName() == "Grandparent.Parent.Child")
assert(child:GetFullName() == "Grandparent.Parent")
assert(model:GetFullName() == "Grandparent")