mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Implement more instance method tests
This commit is contained in:
parent
6895b66550
commit
c43d164c6a
5 changed files with 50 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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()?;
|
||||
|
|
18
tests/roblox/instance/methods/GetChildren.luau
Normal file
18
tests/roblox/instance/methods/GetChildren.luau
Normal 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)
|
18
tests/roblox/instance/methods/GetDescendants.luau
Normal file
18
tests/roblox/instance/methods/GetDescendants.luau
Normal 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)
|
11
tests/roblox/instance/methods/GetFullName.luau
Normal file
11
tests/roblox/instance/methods/GetFullName.luau
Normal 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")
|
Loading…
Reference in a new issue