mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-07-05 19:42:54 +00:00
Fix spacing on all of the rom (#323)
This commit is contained in:
parent
86e0330100
commit
fa70ebcac2
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
(sources
|
(sources
|
||||||
/src/main/resources/assets/computercraft/lua/bios.lua
|
/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 /
|
(at /
|
||||||
(linters
|
(linters
|
||||||
|
@ -93,7 +93,7 @@ if _VERSION == "Lua 5.1" then
|
|||||||
bxor = bit32.bxor,
|
bxor = bit32.bxor,
|
||||||
brshift = bit32.arshift,
|
brshift = bit32.arshift,
|
||||||
blshift = bit32.lshift,
|
blshift = bit32.lshift,
|
||||||
blogic_rshift = bit32.rshift
|
blogic_rshift = bit32.rshift,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -680,7 +680,7 @@ if http then
|
|||||||
|
|
||||||
local methods = {
|
local methods = {
|
||||||
GET = true, POST = true, HEAD = true,
|
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 )
|
local function checkKey( options, key, ty, opt )
|
||||||
@ -925,7 +925,7 @@ if commands and fs.isDir( "rom/apis/command" ) then
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
setmetatable( commands, tCaseInsensitiveMetatable )
|
setmetatable( commands, tCaseInsensitiveMetatable )
|
||||||
setmetatable( commands.async, tCaseInsensitiveMetatable )
|
setmetatable( commands.async, tCaseInsensitiveMetatable )
|
||||||
|
@ -30,7 +30,7 @@ end
|
|||||||
local tAsync = {}
|
local tAsync = {}
|
||||||
local tNonNBTJSONCommands = {
|
local tNonNBTJSONCommands = {
|
||||||
[ "tellraw" ] = true,
|
[ "tellraw" ] = true,
|
||||||
[ "title" ] = true
|
[ "title" ] = true,
|
||||||
}
|
}
|
||||||
local tCommands = native.list()
|
local tCommands = native.list()
|
||||||
for _, sCommandName in ipairs(tCommands) do
|
for _, sCommandName in ipairs(tCommands) do
|
||||||
|
@ -30,7 +30,7 @@ end
|
|||||||
function topics()
|
function topics()
|
||||||
-- Add index
|
-- Add index
|
||||||
local tItems = {
|
local tItems = {
|
||||||
[ "index" ] = true
|
[ "index" ] = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Add topics from the path
|
-- Add topics from the path
|
||||||
|
@ -129,11 +129,11 @@ handleMetatable = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local defaultInput = setmetatable({
|
local defaultInput = setmetatable({
|
||||||
_handle = { readLine = _G.read }
|
_handle = { readLine = _G.read },
|
||||||
}, handleMetatable)
|
}, handleMetatable)
|
||||||
|
|
||||||
local defaultOutput = setmetatable({
|
local defaultOutput = setmetatable({
|
||||||
_handle = { write = _G.write }
|
_handle = { write = _G.write },
|
||||||
}, handleMetatable)
|
}, handleMetatable)
|
||||||
|
|
||||||
local defaultError = setmetatable({
|
local defaultError = setmetatable({
|
||||||
@ -147,7 +147,7 @@ local defaultError = setmetatable({
|
|||||||
_G.write(...)
|
_G.write(...)
|
||||||
if term.isColour() then term.setTextColour(oldColour) end
|
if term.isColour() then term.setTextColour(oldColour) end
|
||||||
end,
|
end,
|
||||||
}
|
},
|
||||||
}, handleMetatable)
|
}, handleMetatable)
|
||||||
|
|
||||||
local currentInput = defaultInput
|
local currentInput = defaultInput
|
||||||
|
@ -46,7 +46,7 @@ local tKeys = {
|
|||||||
nil, "pause", nil, "home", "up", -- 196
|
nil, "pause", nil, "home", "up", -- 196
|
||||||
"pageUp", nil, "left", nil, "right", -- 201
|
"pageUp", nil, "left", nil, "right", -- 201
|
||||||
nil, "end", "down", "pageDown", "insert", -- 206
|
nil, "end", "down", "pageDown", "insert", -- 206
|
||||||
"delete" -- 211
|
"delete", -- 211
|
||||||
}
|
}
|
||||||
|
|
||||||
local keys = _ENV
|
local keys = _ENV
|
||||||
|
@ -241,7 +241,7 @@ end
|
|||||||
empty_json_array = setmetatable({}, {
|
empty_json_array = setmetatable({}, {
|
||||||
__newindex = function()
|
__newindex = function()
|
||||||
error("attempt to mutate textutils.empty_json_array", 2)
|
error("attempt to mutate textutils.empty_json_array", 2)
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function serializeJSONImpl( t, tTracking, bNBTStyle )
|
local function serializeJSONImpl( t, tTracking, bNBTStyle )
|
||||||
|
@ -78,7 +78,7 @@ function new( x, y, z )
|
|||||||
local v = {
|
local v = {
|
||||||
x = tonumber(x) or 0,
|
x = tonumber(x) or 0,
|
||||||
y = tonumber(y) or 0,
|
y = tonumber(y) or 0,
|
||||||
z = tonumber(z) or 0
|
z = tonumber(z) or 0,
|
||||||
}
|
}
|
||||||
setmetatable( v, vmetatable )
|
setmetatable( v, vmetatable )
|
||||||
return v
|
return v
|
||||||
|
@ -456,7 +456,7 @@ function create( parent, nX, nY, nWidth, nHeight, bStartVisible )
|
|||||||
tNewLines[y] = {
|
tNewLines[y] = {
|
||||||
text = sEmptyText,
|
text = sEmptyText,
|
||||||
textColor = sEmptyTextColor,
|
textColor = sEmptyTextColor,
|
||||||
backgroundColor = sEmptyBackgroundColor
|
backgroundColor = sEmptyBackgroundColor,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
local tOldLine = tLines[y]
|
local tOldLine = tLines[y]
|
||||||
|
@ -398,7 +398,7 @@ local tMenuFuncs = {
|
|||||||
sStatus = "Error saving to " .. sTempPath
|
sStatus = "Error saving to " .. sTempPath
|
||||||
end
|
end
|
||||||
redrawMenu()
|
redrawMenu()
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local function doMenuItem( _n )
|
local function doMenuItem( _n )
|
||||||
|
@ -112,7 +112,7 @@ local items = {
|
|||||||
desc = "A perfect handle for torches or a pickaxe.",
|
desc = "A perfect handle for torches or a pickaxe.",
|
||||||
},
|
},
|
||||||
["a crafting table"] = {
|
["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.",
|
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"] = {
|
["a furnace"] = {
|
||||||
@ -270,7 +270,7 @@ local tAnimals = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
local tMonsters = {
|
local tMonsters = {
|
||||||
"a creeper", "a skeleton", "a zombie", "a spider"
|
"a creeper", "a skeleton", "a zombie", "a spider",
|
||||||
}
|
}
|
||||||
|
|
||||||
local tRecipes = {
|
local tRecipes = {
|
||||||
@ -309,7 +309,7 @@ local tGoWest = {
|
|||||||
local nGoWest = 0
|
local nGoWest = 0
|
||||||
|
|
||||||
local bRunning = true
|
local bRunning = true
|
||||||
local tMap = { { {}, }, }
|
local tMap = { { {} } }
|
||||||
local x, y, z = 0, 0, 0
|
local x, y, z = 0, 0, 0
|
||||||
local inventory = {
|
local inventory = {
|
||||||
["no tea"] = items["no tea"],
|
["no tea"] = items["no tea"],
|
||||||
|
@ -54,7 +54,7 @@ local tFruits = {
|
|||||||
"q", "r", "s", "t", "u", "v", "w", "x",
|
"q", "r", "s", "t", "u", "v", "w", "x",
|
||||||
"y", "z",
|
"y", "z",
|
||||||
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
|
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
|
||||||
"@", "$", "%", "#", "&", "!", "?", "+", "*", "~"
|
"@", "$", "%", "#", "&", "!", "?", "+", "*", "~",
|
||||||
}
|
}
|
||||||
|
|
||||||
local function addFruit()
|
local function addFruit()
|
||||||
|
@ -10,16 +10,16 @@ end
|
|||||||
|
|
||||||
local block_s1 = {
|
local block_s1 = {
|
||||||
{
|
{
|
||||||
{ 1,0,0,0, },
|
{ 1, 0, 0, 0 },
|
||||||
{ 1,1,0,0, },
|
{ 1, 1, 0, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 0,1,1,0, },
|
{ 0, 1, 1, 0 },
|
||||||
{ 1,1,0,0, },
|
{ 1, 1, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
ch = colorass(" ", "{}"),
|
ch = colorass(" ", "{}"),
|
||||||
fg = colorass(colors.blue, colors.black),
|
fg = colorass(colors.blue, colors.black),
|
||||||
@ -27,16 +27,16 @@ local block_s1= {
|
|||||||
}
|
}
|
||||||
local block_s2 = {
|
local block_s2 = {
|
||||||
{
|
{
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 1,1,0,0, },
|
{ 1, 1, 0, 0 },
|
||||||
{ 1,0,0,0, },
|
{ 1, 0, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 1,1,0,0, },
|
{ 1, 1, 0, 0 },
|
||||||
{ 0,1,1,0, },
|
{ 0, 1, 1, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
ch = colorass(" ", "{}"),
|
ch = colorass(" ", "{}"),
|
||||||
fg = colorass(colors.green, colors.black),
|
fg = colorass(colors.green, colors.black),
|
||||||
@ -44,16 +44,16 @@ local block_s2= {
|
|||||||
}
|
}
|
||||||
local block_line = {
|
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, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 1,1,1,1, },
|
{ 1, 1, 1, 1 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
ch = colorass(" ", "[]"),
|
ch = colorass(" ", "[]"),
|
||||||
fg = colorass(colors.pink, colors.black),
|
fg = colorass(colors.pink, colors.black),
|
||||||
@ -61,10 +61,10 @@ local block_line = {
|
|||||||
}
|
}
|
||||||
local block_square = {
|
local block_square = {
|
||||||
{
|
{
|
||||||
{ 1,1,0,0, },
|
{ 1, 1, 0, 0 },
|
||||||
{ 1,1,0,0, },
|
{ 1, 1, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
ch = colorass(" ", "[]"),
|
ch = colorass(" ", "[]"),
|
||||||
fg = colorass(colors.lightBlue, colors.black),
|
fg = colorass(colors.lightBlue, colors.black),
|
||||||
@ -72,28 +72,28 @@ local block_square = {
|
|||||||
}
|
}
|
||||||
local block_L1 = {
|
local block_L1 = {
|
||||||
{
|
{
|
||||||
{ 1,1,0,0, },
|
{ 1, 1, 0, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 1,1,1,0, },
|
{ 1, 1, 1, 0 },
|
||||||
{ 1,0,0,0, },
|
{ 1, 0, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,1,1,0, },
|
{ 0, 1, 1, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,0,1,0, },
|
{ 0, 0, 1, 0 },
|
||||||
{ 1,1,1,0, },
|
{ 1, 1, 1, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
ch = colorass(" ", "()"),
|
ch = colorass(" ", "()"),
|
||||||
fg = colorass(colors.orange, colors.black),
|
fg = colorass(colors.orange, colors.black),
|
||||||
@ -101,28 +101,28 @@ local block_L1 = {
|
|||||||
}
|
}
|
||||||
local block_L2 = {
|
local block_L2 = {
|
||||||
{
|
{
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 1,1,0,0, },
|
{ 1, 1, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 1,1,1,0, },
|
{ 1, 1, 1, 0 },
|
||||||
{ 0,0,1,0, },
|
{ 0, 0, 1, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,1,1,0, },
|
{ 0, 1, 1, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 1,0,0,0, },
|
{ 1, 0, 0, 0 },
|
||||||
{ 1,1,1,0, },
|
{ 1, 1, 1, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
ch = colorass(" ", "()"),
|
ch = colorass(" ", "()"),
|
||||||
fg = colorass(colors.brown, colors.black),
|
fg = colorass(colors.brown, colors.black),
|
||||||
@ -130,28 +130,28 @@ local block_L2 = {
|
|||||||
}
|
}
|
||||||
local block_T = {
|
local block_T = {
|
||||||
{
|
{
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 1,1,0,0, },
|
{ 1, 1, 0, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 1,1,1,0, },
|
{ 1, 1, 1, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,1,1,0, },
|
{ 0, 1, 1, 0 },
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{ 0,1,0,0, },
|
{ 0, 1, 0, 0 },
|
||||||
{ 1,1,1,0, },
|
{ 1, 1, 1, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
{ 0,0,0,0, },
|
{ 0, 0, 0, 0 },
|
||||||
},
|
},
|
||||||
ch = colorass(" ", "<>"),
|
ch = colorass(" ", "<>"),
|
||||||
fg = colorass(colors.cyan, colors.black),
|
fg = colorass(colors.cyan, colors.black),
|
||||||
|
@ -70,7 +70,7 @@ local function createShellEnv( sDir )
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil, sError
|
return nil, sError
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
local sentinel = {}
|
local sentinel = {}
|
||||||
@ -397,7 +397,7 @@ function shell.setCompletionFunction( sProgram, fnComplete )
|
|||||||
expect(1, sProgram, "string")
|
expect(1, sProgram, "string")
|
||||||
expect(2, fnComplete, "function")
|
expect(2, fnComplete, "function")
|
||||||
tCompletionInfo[ sProgram ] = {
|
tCompletionInfo[ sProgram ] = {
|
||||||
fnComplete = fnComplete
|
fnComplete = fnComplete,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,19 +11,19 @@
|
|||||||
|
|
||||||
--- Assert an argument to the given function has the specified type.
|
--- Assert an argument to the given function has the specified type.
|
||||||
--
|
--
|
||||||
-- @tparam string The function's name
|
-- @tparam string func The function's name
|
||||||
-- @tparam int The argument index to this function
|
-- @tparam int idx The argument index to this function
|
||||||
-- @tparam string The type this argument should have. May be 'value' for any
|
-- @tparam string ty The type this argument should have. May be 'value' for
|
||||||
-- non-nil value.
|
-- any non-nil value.
|
||||||
-- @param val The value to check
|
-- @param val val The value to check
|
||||||
-- @raise If this value doesn't match the expected type.
|
-- @throws If this value doesn't match the expected type.
|
||||||
local function check(func, arg, ty, val)
|
local function check(func, idx, ty, val)
|
||||||
if ty == 'value' then
|
if ty == 'value' then
|
||||||
if val == nil 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
|
end
|
||||||
elseif type(val) ~= ty then
|
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
|
||||||
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
|
--- Attempt to execute the provided function, gathering a stack trace when it
|
||||||
-- errors.
|
-- errors.
|
||||||
--
|
--
|
||||||
-- @tparam
|
-- @tparam function() fn The function to run
|
||||||
-- @return[1] true
|
-- @return[1] true
|
||||||
-- @return[2] false
|
-- @return[2] false
|
||||||
-- @return[2] The error object
|
-- @return[2] The error object
|
||||||
@ -170,7 +170,7 @@ end
|
|||||||
--- Fail a test with the given message
|
--- Fail a test with the given message
|
||||||
--
|
--
|
||||||
-- @tparam string message The message to fail with
|
-- @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)
|
local function fail(message)
|
||||||
check('fail', 1, 'string', message)
|
check('fail', 1, 'string', message)
|
||||||
error(setmetatable({ message = message, fail = true }, error_mt))
|
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
|
--- Assert that this expectation has the provided value
|
||||||
--
|
--
|
||||||
-- @param value The value to require this expectation to be equal to
|
-- @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)
|
function expect_mt:equals(value)
|
||||||
if value ~= self.value then
|
if value ~= self.value then
|
||||||
fail(("Expected %s\n but got %s"):format(format(value), format(self.value)))
|
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
|
--- Assert that this expectation does not equal the provided value
|
||||||
--
|
--
|
||||||
-- @param value The value to require this expectation to not be equal to
|
-- @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)
|
function expect_mt:not_equals(value)
|
||||||
if value == self.value then
|
if value == self.value then
|
||||||
fail(("Expected any value but %s"):format(format(value)))
|
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
|
--- Assert that this expectation has something of the provided type
|
||||||
--
|
--
|
||||||
-- @tparam string exp_type The type to require this expectation to have
|
-- @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)
|
function expect_mt:type(exp_type)
|
||||||
local actual_type = type(self.value)
|
local actual_type = type(self.value)
|
||||||
if exp_type ~= actual_type then
|
if exp_type ~= actual_type then
|
||||||
@ -270,7 +270,7 @@ end
|
|||||||
-- the provided object.
|
-- the provided object.
|
||||||
--
|
--
|
||||||
-- @param value The value to check for structural equivalence
|
-- @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)
|
function expect_mt:same(value)
|
||||||
if not matches({}, true, self.value, value) then
|
if not matches({}, true, self.value, value) then
|
||||||
fail(("Expected %s\n but got %s"):format(format(value), format(self.value)))
|
fail(("Expected %s\n but got %s"):format(format(value), format(self.value)))
|
||||||
@ -283,7 +283,7 @@ end
|
|||||||
-- in the provided object.
|
-- in the provided object.
|
||||||
--
|
--
|
||||||
-- @param value The value to check against
|
-- @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)
|
function expect_mt:matches(value)
|
||||||
if not matches({}, false, value, self.value) then
|
if not matches({}, false, value, self.value) then
|
||||||
fail(("Expected %s\nto match %s"):format(format(self.value), format(value)))
|
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.
|
-- @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.
|
-- 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)
|
function expect_mt:called(times)
|
||||||
if getmetatable(self.value) ~= stub_mt or self.value.arguments == nil then
|
if getmetatable(self.value) ~= stub_mt or self.value.arguments == nil then
|
||||||
fail(("Expected stubbed function, got %s"):format(type(self.value)))
|
fail(("Expected stubbed function, got %s"):format(type(self.value)))
|
||||||
@ -380,7 +380,7 @@ local expect = setmetatable( {
|
|||||||
-- @return The new expectation
|
-- @return The new expectation
|
||||||
__call = function(_, value)
|
__call = function(_, value)
|
||||||
return setmetatable({ value = value }, expect_mt)
|
return setmetatable({ value = value }, expect_mt)
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
--- The stack of "describe"s.
|
--- The stack of "describe"s.
|
||||||
@ -623,7 +623,7 @@ end
|
|||||||
-- And some summary statistics
|
-- And some summary statistics
|
||||||
local actual_count = tests_run - test_status.pending
|
local actual_count = tests_run - test_status.pending
|
||||||
local info = ("Ran %s test(s), of which %s passed (%g%%).")
|
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
|
if test_status.pending > 0 then
|
||||||
info = info .. (" Skipped %d pending test(s)."):format(test_status.pending)
|
info = info .. (" Skipped %d pending test(s)."):format(test_status.pending)
|
||||||
|
@ -2,7 +2,7 @@ describe("The gps library", function()
|
|||||||
describe("gps.locate", function()
|
describe("gps.locate", function()
|
||||||
it("validates arguments", function()
|
it("validates arguments", function()
|
||||||
stub(_G, "commands", { getBlockPosition = function()
|
stub(_G, "commands", { getBlockPosition = function()
|
||||||
end })
|
end, })
|
||||||
|
|
||||||
gps.locate()
|
gps.locate()
|
||||||
gps.locate(1)
|
gps.locate(1)
|
||||||
|
@ -60,10 +60,10 @@ describe("The io library", function()
|
|||||||
|
|
||||||
expect(io.output():seek()):equal(0)
|
expect(io.output():seek()):equal(0)
|
||||||
assert(io.write("alo alo"))
|
assert(io.write("alo alo"))
|
||||||
expect(io.output():seek()):equal(#("alo alo"))
|
expect(io.output():seek()):equal(#"alo alo")
|
||||||
expect(io.output():seek("cur", -3)):equal(#("alo alo") - 3)
|
expect(io.output():seek("cur", -3)):equal(#"alo alo" - 3)
|
||||||
assert(io.write("joao"))
|
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)
|
expect(io.output():seek("set")):equal(0)
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ describe("The Lua base library", function()
|
|||||||
|
|
||||||
it("does not prefix for unnamed chunks", function()
|
it("does not prefix for unnamed chunks", function()
|
||||||
local info = debug.getinfo(loadstring("return 1"), "S")
|
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)
|
end)
|
||||||
|
|
||||||
it("does not prefix when already prefixed", function()
|
it("does not prefix when already prefixed", function()
|
||||||
|
@ -5,7 +5,7 @@ describe("cc.shell.completion", function()
|
|||||||
it("completes both", function()
|
it("completes both", function()
|
||||||
expect(c.dirOrFile(shell, "rom/")):same {
|
expect(c.dirOrFile(shell, "rom/")):same {
|
||||||
"apis/", "apis", "autorun/", "autorun", "help/", "help",
|
"apis/", "apis", "autorun/", "autorun", "help/", "help",
|
||||||
"modules/", "modules", "motd.txt", "programs/", "programs", "startup.lua"
|
"modules/", "modules", "motd.txt", "programs/", "programs", "startup.lua",
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ describe("The commands program", function()
|
|||||||
it("lists commands", function()
|
it("lists commands", function()
|
||||||
local pagedTabulate = stub(textutils, "pagedTabulate", function(x) print(table.unpack(x)) end)
|
local pagedTabulate = stub(textutils, "pagedTabulate", function(x) print(table.unpack(x)) end)
|
||||||
stub(_G, "commands", {
|
stub(_G, "commands", {
|
||||||
list = function() return { "computercraft" } end
|
list = function() return { "computercraft" } end,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(capture(stub, "/rom/programs/command/commands.lua"))
|
expect(capture(stub, "/rom/programs/command/commands.lua"))
|
||||||
|
@ -15,7 +15,7 @@ describe("The exec program", function()
|
|||||||
|
|
||||||
it("runs a command", function()
|
it("runs a command", function()
|
||||||
stub(_G, "commands", {
|
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"))
|
expect(capture(stub, "/rom/programs/command/exec.lua computercraft"))
|
||||||
@ -24,7 +24,7 @@ describe("The exec program", function()
|
|||||||
|
|
||||||
it("reports command failures", function()
|
it("reports command failures", function()
|
||||||
stub(_G, "commands", {
|
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"))
|
expect(capture(stub, "/rom/programs/command/exec.lua computercraft"))
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local capture = require "test_helpers".capture_program
|
local capture = require "test_helpers".capture_program
|
||||||
local testFile = require "test_helpers".testFile
|
|
||||||
|
|
||||||
describe("The edit program", function()
|
describe("The edit program", function()
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ describe("The pastebin program", function()
|
|||||||
local tHeader = {}
|
local tHeader = {}
|
||||||
tHeader["Content-Type"] = "text/plain; charset=utf-8"
|
tHeader["Content-Type"] = "text/plain; charset=utf-8"
|
||||||
return tHeader
|
return tHeader
|
||||||
end
|
end,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
post = function()
|
post = function()
|
||||||
@ -28,7 +28,7 @@ describe("The pastebin program", function()
|
|||||||
close = function()
|
close = function()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ describe("The wget program", function()
|
|||||||
close = function()
|
close = function()
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ describe("The pocket equip program", function()
|
|||||||
|
|
||||||
it("can equip an upgrade", function()
|
it("can equip an upgrade", function()
|
||||||
stub(_G, "pocket", {
|
stub(_G, "pocket", {
|
||||||
equipBack = function() return true end
|
equipBack = function() return true end,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(capture(stub, "/rom/programs/pocket/equip.lua"))
|
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()
|
it("handles when an upgrade cannot be equipped", function()
|
||||||
stub(_G, "pocket", {
|
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"))
|
expect(capture(stub, "/rom/programs/pocket/equip.lua"))
|
||||||
|
@ -9,7 +9,7 @@ describe("The pocket unequip program", function()
|
|||||||
|
|
||||||
it("unequips an upgrade", function()
|
it("unequips an upgrade", function()
|
||||||
stub(_G, "pocket", {
|
stub(_G, "pocket", {
|
||||||
unequipBack = function() return true end
|
unequipBack = function() return true end,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(capture(stub, "/rom/programs/pocket/unequip.lua"))
|
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()
|
it("handles when an upgrade cannot be equipped", function()
|
||||||
stub(_G, "pocket", {
|
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"))
|
expect(capture(stub, "/rom/programs/pocket/unequip.lua"))
|
||||||
|
@ -17,7 +17,7 @@ describe("The refuel program", function()
|
|||||||
end,
|
end,
|
||||||
getFuelLimit = function()
|
getFuelLimit = function()
|
||||||
return fuel_limit
|
return fuel_limit
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ describe("The turtle unequip program", function()
|
|||||||
select = function() end,
|
select = function() end,
|
||||||
getItemCount = function() return 0 end,
|
getItemCount = function() return 0 end,
|
||||||
equipRight = function() return true 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"))
|
expect(capture(stub, "/rom/programs/turtle/unequip.lua left"))
|
||||||
@ -42,7 +42,7 @@ describe("The turtle unequip program", function()
|
|||||||
equipLeft = function()
|
equipLeft = function()
|
||||||
item_count = 1
|
item_count = 1
|
||||||
return true
|
return true
|
||||||
end
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(capture(stub, "/rom/programs/turtle/unequip.lua left"))
|
expect(capture(stub, "/rom/programs/turtle/unequip.lua left"))
|
||||||
@ -57,7 +57,7 @@ describe("The turtle unequip program", function()
|
|||||||
select = function() end,
|
select = function() end,
|
||||||
getItemCount = function() return 1 end,
|
getItemCount = function() return 1 end,
|
||||||
equipRight = function() return true 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"))
|
expect(capture(stub, "/rom/programs/turtle/unequip.lua left"))
|
||||||
|
@ -37,7 +37,7 @@ local function capture_program(stub, program, ...)
|
|||||||
output = table.concat(output),
|
output = table.concat(output),
|
||||||
error = table.concat(error),
|
error = table.concat(error),
|
||||||
combined = table.concat(combined),
|
combined = table.concat(combined),
|
||||||
ok = ok
|
ok = ok,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user