mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-12 03:00:30 +00:00
Forbid mutating empty_json_array
It's definitely still possible (rawset), but should prevent people accidentally trying to modify it when they shouldn't.
This commit is contained in:
parent
0cb659d78c
commit
e839ef54af
@ -240,7 +240,11 @@ local function serializeImpl( t, tTracking, sIndent )
|
||||
end
|
||||
end
|
||||
|
||||
empty_json_array = {}
|
||||
empty_json_array = setmetatable({}, {
|
||||
__newindex = function()
|
||||
error("attempt to mutate textutils.empty_json_array", 2)
|
||||
end
|
||||
})
|
||||
|
||||
local function serializeJSONImpl( t, tTracking, bNBTStyle )
|
||||
local sType = type(t)
|
||||
|
@ -20,6 +20,13 @@ describe("The textutils library", function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("textutils.empty_json_array", function()
|
||||
it("is immutable", function()
|
||||
expect.error(function() textutils.empty_json_array[1] = true end)
|
||||
:eq("textutils_spec.lua:25: attempt to mutate textutils.empty_json_array")
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("textutils.unserialise", function()
|
||||
it("validates arguments", function()
|
||||
textutils.unserialise("")
|
||||
|
Loading…
Reference in New Issue
Block a user