Fix spacing on all of the rom (#323)

This commit is contained in:
Jonathan Coates 2019-12-07 10:33:47 +00:00 committed by GitHub
parent 86e0330100
commit fa70ebcac2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 1032 additions and 1032 deletions

View File

@ -2,7 +2,8 @@
(sources
/src/main/resources/assets/computercraft/lua/bios.lua
/src/main/resources/assets/computercraft/lua/rom/)
/src/main/resources/assets/computercraft/lua/rom/
/src/test/resources/test-rom)
(at /
(linters

View File

@ -93,7 +93,7 @@ if _VERSION == "Lua 5.1" then
bxor = bit32.bxor,
brshift = bit32.arshift,
blshift = bit32.lshift,
blogic_rshift = bit32.rshift
blogic_rshift = bit32.rshift,
}
end
end
@ -680,7 +680,7 @@ if http then
local methods = {
GET = true, POST = true, HEAD = true,
OPTIONS = true, PUT = true, DELETE = true
OPTIONS = true, PUT = true, DELETE = true,
}
local function checkKey( options, key, ty, opt )
@ -925,7 +925,7 @@ if commands and fs.isDir( "rom/apis/command" ) then
end
end
return nil
end
end,
}
setmetatable( commands, tCaseInsensitiveMetatable )
setmetatable( commands.async, tCaseInsensitiveMetatable )

View File

@ -30,7 +30,7 @@ end
local tAsync = {}
local tNonNBTJSONCommands = {
[ "tellraw" ] = true,
[ "title" ] = true
[ "title" ] = true,
}
local tCommands = native.list()
for _, sCommandName in ipairs(tCommands) do

View File

@ -30,7 +30,7 @@ end
function topics()
-- Add index
local tItems = {
[ "index" ] = true
[ "index" ] = true,
}
-- Add topics from the path

View File

@ -129,11 +129,11 @@ handleMetatable = {
}
local defaultInput = setmetatable({
_handle = { readLine = _G.read }
_handle = { readLine = _G.read },
}, handleMetatable)
local defaultOutput = setmetatable({
_handle = { write = _G.write }
_handle = { write = _G.write },
}, handleMetatable)
local defaultError = setmetatable({
@ -147,7 +147,7 @@ local defaultError = setmetatable({
_G.write(...)
if term.isColour() then term.setTextColour(oldColour) end
end,
}
},
}, handleMetatable)
local currentInput = defaultInput

View File

@ -46,7 +46,7 @@ local tKeys = {
nil, "pause", nil, "home", "up", -- 196
"pageUp", nil, "left", nil, "right", -- 201
nil, "end", "down", "pageDown", "insert", -- 206
"delete" -- 211
"delete", -- 211
}
local keys = _ENV

View File

@ -241,7 +241,7 @@ end
empty_json_array = setmetatable({}, {
__newindex = function()
error("attempt to mutate textutils.empty_json_array", 2)
end
end,
})
local function serializeJSONImpl( t, tTracking, bNBTStyle )

View File

@ -78,7 +78,7 @@ function new( x, y, z )
local v = {
x = tonumber(x) or 0,
y = tonumber(y) or 0,
z = tonumber(z) or 0
z = tonumber(z) or 0,
}
setmetatable( v, vmetatable )
return v

View File

@ -456,7 +456,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
tNewLines[y] = {
text = sEmptyText,
textColor = sEmptyTextColor,
backgroundColor = sEmptyBackgroundColor
backgroundColor = sEmptyBackgroundColor,
}
else
local tOldLine = tLines[y]

View File

@ -398,7 +398,7 @@ local tMenuFuncs = {
sStatus = "Error saving to " .. sTempPath
end
redrawMenu()
end
end,
}
local function doMenuItem( _n )

View File

@ -112,7 +112,7 @@ local items = {
desc = "A perfect handle for torches or a pickaxe.",
},
["a crafting table"] = {
aliases = { "crafting table", "craft table", "work bench", "workbench", "crafting bench", "table", },
aliases = { "crafting table", "craft table", "work bench", "workbench", "crafting bench", "table" },
desc = "It's a crafting table. I shouldn't tell you this, but these don't actually do anything in this game, you can craft tools whenever you like.",
},
["a furnace"] = {
@ -270,7 +270,7 @@ local tAnimals = {
}
local tMonsters = {
"a creeper", "a skeleton", "a zombie", "a spider"
"a creeper", "a skeleton", "a zombie", "a spider",
}
local tRecipes = {
@ -309,7 +309,7 @@ local tGoWest = {
local nGoWest = 0
local bRunning = true
local tMap = { { {}, }, }
local tMap = { { {} } }
local x, y, z = 0, 0, 0
local inventory = {
["no tea"] = items["no tea"],

View File

@ -54,7 +54,7 @@ local tFruits = {
"q", "r", "s", "t", "u", "v", "w", "x",
"y", "z",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
"@", "$", "%", "#", "&", "!", "?", "+", "*", "~"
"@", "$", "%", "#", "&", "!", "?", "+", "*", "~",
}
local function addFruit()

View File

@ -10,16 +10,16 @@ end
local block_s1 = {
{
{ 1,0,0,0, },
{ 1,1,0,0, },
{ 0,1,0,0, },
{ 0,0,0,0, },
{ 1, 0, 0, 0 },
{ 1, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,0,0,0, },
{ 0,1,1,0, },
{ 1,1,0,0, },
{ 0,0,0,0, },
{ 0, 0, 0, 0 },
{ 0, 1, 1, 0 },
{ 1, 1, 0, 0 },
{ 0, 0, 0, 0 },
},
ch = colorass(" ", "{}"),
fg = colorass(colors.blue, colors.black),
@ -27,16 +27,16 @@ local block_s1= {
}
local block_s2 = {
{
{ 0,1,0,0, },
{ 1,1,0,0, },
{ 1,0,0,0, },
{ 0,0,0,0, },
{ 0, 1, 0, 0 },
{ 1, 1, 0, 0 },
{ 1, 0, 0, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,0,0,0, },
{ 1,1,0,0, },
{ 0,1,1,0, },
{ 0,0,0,0, },
{ 0, 0, 0, 0 },
{ 1, 1, 0, 0 },
{ 0, 1, 1, 0 },
{ 0, 0, 0, 0 },
},
ch = colorass(" ", "{}"),
fg = colorass(colors.green, colors.black),
@ -44,16 +44,16 @@ local block_s2= {
}
local block_line = {
{
{ 0,1,0,0, },
{ 0,1,0,0, },
{ 0,1,0,0, },
{ 0,1,0,0, },
{ 0, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 1, 0, 0 },
},
{
{ 0,0,0,0, },
{ 1,1,1,1, },
{ 0,0,0,0, },
{ 0,0,0,0, },
{ 0, 0, 0, 0 },
{ 1, 1, 1, 1 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
},
ch = colorass(" ", "[]"),
fg = colorass(colors.pink, colors.black),
@ -61,10 +61,10 @@ local block_line = {
}
local block_square = {
{
{ 1,1,0,0, },
{ 1,1,0,0, },
{ 0,0,0,0, },
{ 0,0,0,0, },
{ 1, 1, 0, 0 },
{ 1, 1, 0, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
},
ch = colorass(" ", "[]"),
fg = colorass(colors.lightBlue, colors.black),
@ -72,28 +72,28 @@ local block_square = {
}
local block_L1 = {
{
{ 1,1,0,0, },
{ 0,1,0,0, },
{ 0,1,0,0, },
{ 0,0,0,0, },
{ 1, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,0,0,0, },
{ 1,1,1,0, },
{ 1,0,0,0, },
{ 0,0,0,0, },
{ 0, 0, 0, 0 },
{ 1, 1, 1, 0 },
{ 1, 0, 0, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,1,0,0, },
{ 0,1,0,0, },
{ 0,1,1,0, },
{ 0,0,0,0, },
{ 0, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 1, 1, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,0,1,0, },
{ 1,1,1,0, },
{ 0,0,0,0, },
{ 0,0,0,0, },
{ 0, 0, 1, 0 },
{ 1, 1, 1, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
},
ch = colorass(" ", "()"),
fg = colorass(colors.orange, colors.black),
@ -101,28 +101,28 @@ local block_L1 = {
}
local block_L2 = {
{
{ 0,1,0,0, },
{ 0,1,0,0, },
{ 1,1,0,0, },
{ 0,0,0,0, },
{ 0, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 1, 1, 0, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,0,0,0, },
{ 1,1,1,0, },
{ 0,0,1,0, },
{ 0,0,0,0, },
{ 0, 0, 0, 0 },
{ 1, 1, 1, 0 },
{ 0, 0, 1, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,1,1,0, },
{ 0,1,0,0, },
{ 0,1,0,0, },
{ 0,0,0,0, },
{ 0, 1, 1, 0 },
{ 0, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 0, 0 },
},
{
{ 1,0,0,0, },
{ 1,1,1,0, },
{ 0,0,0,0, },
{ 0,0,0,0, },
{ 1, 0, 0, 0 },
{ 1, 1, 1, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
},
ch = colorass(" ", "()"),
fg = colorass(colors.brown, colors.black),
@ -130,28 +130,28 @@ local block_L2 = {
}
local block_T = {
{
{ 0,1,0,0, },
{ 1,1,0,0, },
{ 0,1,0,0, },
{ 0,0,0,0, },
{ 0, 1, 0, 0 },
{ 1, 1, 0, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,0,0,0, },
{ 1,1,1,0, },
{ 0,1,0,0, },
{ 0,0,0,0, },
{ 0, 0, 0, 0 },
{ 1, 1, 1, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,1,0,0, },
{ 0,1,1,0, },
{ 0,1,0,0, },
{ 0,0,0,0, },
{ 0, 1, 0, 0 },
{ 0, 1, 1, 0 },
{ 0, 1, 0, 0 },
{ 0, 0, 0, 0 },
},
{
{ 0,1,0,0, },
{ 1,1,1,0, },
{ 0,0,0,0, },
{ 0,0,0,0, },
{ 0, 1, 0, 0 },
{ 1, 1, 1, 0 },
{ 0, 0, 0, 0 },
{ 0, 0, 0, 0 },
},
ch = colorass(" ", "<>"),
fg = colorass(colors.cyan, colors.black),

View File

@ -70,7 +70,7 @@ local function createShellEnv( sDir )
end
end
return nil, sError
end
end,
}
local sentinel = {}
@ -397,7 +397,7 @@ function shell.setCompletionFunction( sProgram, fnComplete )
expect(1, sProgram, "string")
expect(2, fnComplete, "function")
tCompletionInfo[ sProgram ] = {
fnComplete = fnComplete
fnComplete = fnComplete,
}
end

View File

@ -11,19 +11,19 @@
--- Assert an argument to the given function has the specified type.
--
-- @tparam string The function's name
-- @tparam int The argument index to this function
-- @tparam string The type this argument should have. May be 'value' for any
-- non-nil value.
-- @param val The value to check
-- @raise If this value doesn't match the expected type.
local function check(func, arg, ty, val)
-- @tparam string func The function's name
-- @tparam int idx The argument index to this function
-- @tparam string ty The type this argument should have. May be 'value' for
-- any non-nil value.
-- @param val val The value to check
-- @throws If this value doesn't match the expected type.
local function check(func, idx, ty, val)
if ty == 'value' then
if val == nil then
error(('%s: bad argument #%d (got nil)'):format(func, arg), 3)
error(('%s: bad argument #%d (got nil)'):format(func, idx), 3)
end
elseif type(val) ~= ty then
return error(('%s: bad argument #%d (expected %s, got %s)'):format(func, arg, ty, type(val)), 3)
return error(('%s: bad argument #%d (expected %s, got %s)'):format(func, idx, ty, type(val)), 3)
end
end
@ -122,7 +122,7 @@ local error_mt = { __tostring = function(self) return self.message end }
--- Attempt to execute the provided function, gathering a stack trace when it
-- errors.
--
-- @tparam
-- @tparam function() fn The function to run
-- @return[1] true
-- @return[2] false
-- @return[2] The error object
@ -170,7 +170,7 @@ end
--- Fail a test with the given message
--
-- @tparam string message The message to fail with
-- @raises An error with the given message
-- @throws An error with the given message
local function fail(message)
check('fail', 1, 'string', message)
error(setmetatable({ message = message, fail = true }, error_mt))
@ -192,7 +192,7 @@ expect_mt.__index = expect_mt
--- Assert that this expectation has the provided value
--
-- @param value The value to require this expectation to be equal to
-- @raises If the values are not equal
-- @throws If the values are not equal
function expect_mt:equals(value)
if value ~= self.value then
fail(("Expected %s\n but got %s"):format(format(value), format(self.value)))
@ -206,7 +206,7 @@ expect_mt.eq = expect_mt.equals
--- Assert that this expectation does not equal the provided value
--
-- @param value The value to require this expectation to not be equal to
-- @raises If the values are equal
-- @throws If the values are equal
function expect_mt:not_equals(value)
if value == self.value then
fail(("Expected any value but %s"):format(format(value)))
@ -220,7 +220,7 @@ expect_mt.ne = expect_mt.not_equals
--- Assert that this expectation has something of the provided type
--
-- @tparam string exp_type The type to require this expectation to have
-- @raises If it does not have that thpe
-- @throws If it does not have that thpe
function expect_mt:type(exp_type)
local actual_type = type(self.value)
if exp_type ~= actual_type then
@ -270,7 +270,7 @@ end
-- the provided object.
--
-- @param value The value to check for structural equivalence
-- @raises If they are not equivalent
-- @throws If they are not equivalent
function expect_mt:same(value)
if not matches({}, true, self.value, value) then
fail(("Expected %s\n but got %s"):format(format(value), format(self.value)))
@ -283,7 +283,7 @@ end
-- in the provided object.
--
-- @param value The value to check against
-- @raises If this does not match the provided value
-- @throws If this does not match the provided value
function expect_mt:matches(value)
if not matches({}, false, value, self.value) then
fail(("Expected %s\nto match %s"):format(format(self.value), format(value)))
@ -296,7 +296,7 @@ end
--
-- @tparam[opt] number The exact number of times the function must be called.
-- If not given just require the function to be called at least once.
-- @raises If this function was not called the expected number of times.
-- @throws If this function was not called the expected number of times.
function expect_mt:called(times)
if getmetatable(self.value) ~= stub_mt or self.value.arguments == nil then
fail(("Expected stubbed function, got %s"):format(type(self.value)))
@ -380,7 +380,7 @@ local expect = setmetatable( {
-- @return The new expectation
__call = function(_, value)
return setmetatable({ value = value }, expect_mt)
end
end,
})
--- The stack of "describe"s.
@ -623,7 +623,7 @@ end
-- And some summary statistics
local actual_count = tests_run - test_status.pending
local info = ("Ran %s test(s), of which %s passed (%g%%).")
:format(actual_count, test_status.pass, (test_status.pass / actual_count) * 100)
:format(actual_count, test_status.pass, test_status.pass / actual_count * 100)
if test_status.pending > 0 then
info = info .. (" Skipped %d pending test(s)."):format(test_status.pending)

View File

@ -2,7 +2,7 @@ describe("The gps library", function()
describe("gps.locate", function()
it("validates arguments", function()
stub(_G, "commands", { getBlockPosition = function()
end })
end, })
gps.locate()
gps.locate(1)

View File

@ -60,10 +60,10 @@ describe("The io library", function()
expect(io.output():seek()):equal(0)
assert(io.write("alo alo"))
expect(io.output():seek()):equal(#("alo alo"))
expect(io.output():seek("cur", -3)):equal(#("alo alo") - 3)
expect(io.output():seek()):equal(#"alo alo")
expect(io.output():seek("cur", -3)):equal(#"alo alo" - 3)
assert(io.write("joao"))
expect(io.output():seek("end"):equal(#("alo joao")))
expect(io.output():seek("end"):equal(#"alo joao"))
expect(io.output():seek("set")):equal(0)

View File

@ -70,7 +70,7 @@ describe("The Lua base library", function()
it("does not prefix for unnamed chunks", function()
local info = debug.getinfo(loadstring("return 1"), "S")
expect(info):matches { short_src = '[string "return 1"]', source = "return 1", }
expect(info):matches { short_src = '[string "return 1"]', source = "return 1" }
end)
it("does not prefix when already prefixed", function()

View File

@ -5,7 +5,7 @@ describe("cc.shell.completion", function()
it("completes both", function()
expect(c.dirOrFile(shell, "rom/")):same {
"apis/", "apis", "autorun/", "autorun", "help/", "help",
"modules/", "modules", "motd.txt", "programs/", "programs", "startup.lua"
"modules/", "modules", "motd.txt", "programs/", "programs", "startup.lua",
}
end)

View File

@ -10,7 +10,7 @@ describe("The commands program", function()
it("lists commands", function()
local pagedTabulate = stub(textutils, "pagedTabulate", function(x) print(table.unpack(x)) end)
stub(_G, "commands", {
list = function() return { "computercraft" } end
list = function() return { "computercraft" } end,
})
expect(capture(stub, "/rom/programs/command/commands.lua"))

View File

@ -15,7 +15,7 @@ describe("The exec program", function()
it("runs a command", function()
stub(_G, "commands", {
exec = function() return true, {"Hello World!"} end
exec = function() return true, {"Hello World!"} end,
})
expect(capture(stub, "/rom/programs/command/exec.lua computercraft"))
@ -24,7 +24,7 @@ describe("The exec program", function()
it("reports command failures", function()
stub(_G, "commands", {
exec = function() return false, {"Hello World!"} end
exec = function() return false, {"Hello World!"} end,
})
expect(capture(stub, "/rom/programs/command/exec.lua computercraft"))

View File

@ -1,5 +1,4 @@
local capture = require "test_helpers".capture_program
local testFile = require "test_helpers".testFile
describe("The edit program", function()

View File

@ -17,7 +17,7 @@ describe("The pastebin program", function()
local tHeader = {}
tHeader["Content-Type"] = "text/plain; charset=utf-8"
return tHeader
end
end,
}
end,
post = function()
@ -28,7 +28,7 @@ describe("The pastebin program", function()
close = function()
end,
}
end
end,
})
end

View File

@ -14,7 +14,7 @@ describe("The wget program", function()
close = function()
end,
}
end
end,
})
end

View File

@ -9,7 +9,7 @@ describe("The pocket equip program", function()
it("can equip an upgrade", function()
stub(_G, "pocket", {
equipBack = function() return true end
equipBack = function() return true end,
})
expect(capture(stub, "/rom/programs/pocket/equip.lua"))
@ -18,7 +18,7 @@ describe("The pocket equip program", function()
it("handles when an upgrade cannot be equipped", function()
stub(_G, "pocket", {
equipBack = function() return false, "Cannot equip this item." end
equipBack = function() return false, "Cannot equip this item." end,
})
expect(capture(stub, "/rom/programs/pocket/equip.lua"))

View File

@ -9,7 +9,7 @@ describe("The pocket unequip program", function()
it("unequips an upgrade", function()
stub(_G, "pocket", {
unequipBack = function() return true end
unequipBack = function() return true end,
})
expect(capture(stub, "/rom/programs/pocket/unequip.lua"))
@ -18,7 +18,7 @@ describe("The pocket unequip program", function()
it("handles when an upgrade cannot be equipped", function()
stub(_G, "pocket", {
unequipBack = function() return false, "Nothing to remove." end
unequipBack = function() return false, "Nothing to remove." end,
})
expect(capture(stub, "/rom/programs/pocket/unequip.lua"))

View File

@ -17,7 +17,7 @@ describe("The refuel program", function()
end,
getFuelLimit = function()
return fuel_limit
end
end,
})
end

View File

@ -21,7 +21,7 @@ describe("The turtle unequip program", function()
select = function() end,
getItemCount = function() return 0 end,
equipRight = function() return true end,
equipLeft = function() return true end
equipLeft = function() return true end,
})
expect(capture(stub, "/rom/programs/turtle/unequip.lua left"))
@ -42,7 +42,7 @@ describe("The turtle unequip program", function()
equipLeft = function()
item_count = 1
return true
end
end,
})
expect(capture(stub, "/rom/programs/turtle/unequip.lua left"))
@ -57,7 +57,7 @@ describe("The turtle unequip program", function()
select = function() end,
getItemCount = function() return 1 end,
equipRight = function() return true end,
equipLeft = function() return true end
equipLeft = function() return true end,
})
expect(capture(stub, "/rom/programs/turtle/unequip.lua left"))

View File

@ -37,7 +37,7 @@ local function capture_program(stub, program, ...)
output = table.concat(output),
error = table.concat(error),
combined = table.concat(combined),
ok = ok
ok = ok,
}
end