mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-20 12:45:05 +00:00
* Implement ChangeBatcher * Use ChangeBatcher for two-way sync * Pause updates during patch application * I can English good * Break after encountering a nil Parent change This prevents __flush from erroring out when an instance's Parent is changed to nil and it has other property changes in the same batch. * Update rbx_dom_lua * Don't connect changed listeners in a running game #468 made me realize how bad of an idea this is in general... * Update TestEZ and fix sibling Ref reification test * Add ChangeBatcher tests * Test instance unpausing by breaking functionality out to __cycle * Break up the module a bit and improve tests * Shuffle requires around and edit comment * Break out more stuff, rename createChangePatch -> createPatchSet * Make ChangeBatcher responsible for unpausing all paused instances This somewhat improves the situation (of course, it would preferrable to not have to hack around this problem with Source at all). It also sets us up nicely if we come across any other properties that do anything similar. * Remove old reference to pausedBatchInstances * Use RenderStepped instead of Heartbeat and trash multi-frame pauses I probably should have done this in the first place... ChangeBatcher still needs to unpause instances, but we don't need to hold pauses for any longer than one cycle. * Remove useless branch * if not next(x) -> if next(x) == nil * Add InstanceMap:unpauseAllInstances, use it in ChangeBatcher * Move IsRunning check to InstanceMap:__maybeFireInstanceChanged
75 lines
1.6 KiB
Lua
75 lines
1.6 KiB
Lua
return function()
|
|
local PatchSet = require(script.Parent.Parent.PatchSet)
|
|
local InstanceMap = require(script.Parent.Parent.InstanceMap)
|
|
|
|
local createPatchSet = require(script.Parent.createPatchSet)
|
|
|
|
it("should return a patch", function()
|
|
local patch = createPatchSet(InstanceMap.new(), {})
|
|
|
|
assert(PatchSet.validate(patch))
|
|
end)
|
|
|
|
it("should contain updates for every instance with property changes", function()
|
|
local instanceMap = InstanceMap.new()
|
|
|
|
local part1 = Instance.new("Part")
|
|
instanceMap:insert("PART_1", part1)
|
|
|
|
local part2 = Instance.new("Part")
|
|
instanceMap:insert("PART_2", part2)
|
|
|
|
local changes = {
|
|
[part1] = {
|
|
Position = true,
|
|
Size = true,
|
|
Color = true,
|
|
},
|
|
[part2] = {
|
|
CFrame = true,
|
|
Velocity = true,
|
|
Transparency = true,
|
|
},
|
|
}
|
|
|
|
local patch = createPatchSet(instanceMap, changes)
|
|
|
|
expect(#patch.updated).to.equal(2)
|
|
end)
|
|
|
|
it("should not contain any updates for removed instances", function()
|
|
local instanceMap = InstanceMap.new()
|
|
|
|
local part1 = Instance.new("Part")
|
|
instanceMap:insert("PART_1", part1)
|
|
|
|
local changes = {
|
|
[part1] = {
|
|
Parent = true,
|
|
Position = true,
|
|
Size = true,
|
|
},
|
|
}
|
|
|
|
local patch = createPatchSet(instanceMap, changes)
|
|
|
|
expect(#patch.removed).to.equal(1)
|
|
expect(#patch.updated).to.equal(0)
|
|
end)
|
|
|
|
it("should remove instances from the property change table", function()
|
|
local instanceMap = InstanceMap.new()
|
|
|
|
local part1 = Instance.new("Part")
|
|
instanceMap:insert("PART_1", part1)
|
|
|
|
local changes = {
|
|
[part1] = {},
|
|
}
|
|
|
|
createPatchSet(instanceMap, changes)
|
|
|
|
expect(next(changes)).to.equal(nil)
|
|
end)
|
|
end
|