mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-11-21 15:54:47 +00:00
Use select('#', ...) instead of ipairs on varargs
This means we don't discard any value after nil, meaning that calls such as colors.combine(nil, 1, 2, 3) will error, rather than returning 0.
This commit is contained in:
@@ -20,10 +20,36 @@ describe("The textutils library", function()
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("textutils.tabulate", function()
|
||||
it("validates arguments", function()
|
||||
term.redirect(window.create(term.current(), 1, 1, 5, 5, false))
|
||||
|
||||
textutils.tabulate()
|
||||
textutils.tabulate({ "test" })
|
||||
textutils.tabulate(colors.white)
|
||||
|
||||
expect.error(textutils.tabulate, nil):eq("bad argument #1 (expected number or table, got nil)")
|
||||
expect.error(textutils.tabulate, { "test" }, nil):eq("bad argument #2 (expected number or table, got nil)")
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("textutils.pagedTabulate", function()
|
||||
it("validates arguments", function()
|
||||
term.redirect(window.create(term.current(), 1, 1, 5, 5, false))
|
||||
|
||||
textutils.pagedTabulate()
|
||||
textutils.pagedTabulate({ "test" })
|
||||
textutils.pagedTabulate(colors.white)
|
||||
|
||||
expect.error(textutils.pagedTabulate, nil):eq("bad argument #1 (expected number or table, got nil)")
|
||||
expect.error(textutils.pagedTabulate, { "test" }, nil):eq("bad argument #2 (expected number or table, got nil)")
|
||||
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")
|
||||
:eq("textutils_spec.lua:51: attempt to mutate textutils.empty_json_array")
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user