2023-05-20 13:23:51 +01:00
|
|
|
local fs = require("@lune/fs")
|
2023-05-20 18:49:37 +01:00
|
|
|
local roblox = require("@lune/roblox")
|
2023-05-20 13:23:51 +01:00
|
|
|
local Instance = roblox.Instance
|
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
-- Smoke tests
|
|
|
|
do
|
|
|
|
local game = Instance.new("DataModel")
|
2023-05-20 13:23:51 +01:00
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
local workspace = game:GetService("Workspace")
|
2023-05-20 13:23:51 +01:00
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
local model = Instance.new("Model")
|
|
|
|
local part = Instance.new("Part")
|
2023-05-20 13:23:51 +01:00
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
part.Parent = model
|
|
|
|
model.Parent = workspace
|
2023-05-20 13:23:51 +01:00
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
local placeAsBinary = roblox.serializePlace(game)
|
|
|
|
local placeAsXml = roblox.serializePlace(game, true)
|
2023-05-20 13:23:51 +01:00
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
fs.writeFile("bin/temp-place.rbxl", placeAsBinary)
|
|
|
|
fs.writeFile("bin/temp-place.rbxlx", placeAsXml)
|
2023-05-20 13:23:51 +01:00
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
local savedFileBinary = fs.readFile("bin/temp-place.rbxl")
|
|
|
|
local savedFileXml = fs.readFile("bin/temp-place.rbxlx")
|
2023-05-20 13:23:51 +01:00
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
local savedBinary = roblox.deserializePlace(savedFileBinary)
|
|
|
|
local savedXml = roblox.deserializePlace(savedFileXml)
|
2023-05-20 13:23:51 +01:00
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
assert(savedBinary.Name ~= "ROOT")
|
|
|
|
assert(savedXml.Name ~= "ROOT")
|
2023-05-20 13:23:51 +01:00
|
|
|
|
2023-10-04 20:25:26 +01:00
|
|
|
assert(savedBinary.ClassName == "DataModel")
|
|
|
|
assert(savedXml.ClassName == "DataModel")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Ensure Ref properties are preserved across services
|
|
|
|
do
|
|
|
|
local game = Instance.new("DataModel")
|
|
|
|
local ReplicatedStorage = Instance.new("ReplicatedStorage")
|
|
|
|
local Workspace = Instance.new("Workspace")
|
|
|
|
|
|
|
|
Workspace.Parent = game
|
|
|
|
ReplicatedStorage.Parent = game
|
|
|
|
|
|
|
|
local part = Instance.new("Part")
|
|
|
|
part.Parent = ReplicatedStorage
|
|
|
|
|
|
|
|
local objectValue = Instance.new("ObjectValue") :: any
|
|
|
|
objectValue.Value = part
|
|
|
|
objectValue.Parent = Workspace
|
|
|
|
|
|
|
|
local serialized = roblox.serializePlace(game)
|
|
|
|
local deserialized = roblox.deserializePlace(serialized) :: any
|
|
|
|
|
|
|
|
assert(deserialized.Workspace.ObjectValue.Value == deserialized.ReplicatedStorage.Part)
|
|
|
|
end
|