mirror of
https://github.com/kikito/inspect.lua.git
synced 2024-12-15 14:34:21 +00:00
Retab & spacing
This commit is contained in:
parent
f8da52ca3d
commit
1ca5576b59
@ -177,10 +177,10 @@ local function makePath(path, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function processRecursive(process, item, path, visited)
|
local function processRecursive(process, item, path, visited)
|
||||||
|
|
||||||
if item == nil then return nil end
|
if item == nil then return nil end
|
||||||
if visited[item] then return visited[item] end
|
if visited[item] then return visited[item] end
|
||||||
|
|
||||||
local processed = process(item, path)
|
local processed = process(item, path)
|
||||||
if type(processed) == 'table' then
|
if type(processed) == 'table' then
|
||||||
local processedCopy = {}
|
local processedCopy = {}
|
||||||
|
@ -27,15 +27,15 @@ describe( 'inspect', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('escapes newlines properly', function()
|
it('escapes newlines properly', function()
|
||||||
assert.equals('"I have \\n new \\n lines"', inspect('I have \n new \n lines'))
|
assert.equals('"I have \\n new \\n lines"', inspect('I have \n new \n lines'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('escapes tabs properly', function()
|
it('escapes tabs properly', function()
|
||||||
assert.equals('"I have \\t a tab character"', inspect('I have \t a tab character'))
|
assert.equals('"I have \\t a tab character"', inspect('I have \t a tab character'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('escapes backspaces properly', function()
|
it('escapes backspaces properly', function()
|
||||||
assert.equals('"I have \\b a back space"', inspect('I have \b a back space'))
|
assert.equals('"I have \\b a back space"', inspect('I have \b a back space'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('escapes zeroes and other control characters properly', function()
|
it('escapes zeroes and other control characters properly', function()
|
||||||
@ -44,9 +44,9 @@ describe( 'inspect', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('backslashes its backslashes', function()
|
it('backslashes its backslashes', function()
|
||||||
assert.equals('"I have \\\\ a backslash"', inspect('I have \\ a backslash'))
|
assert.equals('"I have \\\\ a backslash"', inspect('I have \\ a backslash'))
|
||||||
assert.equals('"I have \\\\\\\\ two backslashes"', inspect('I have \\\\ two backslashes'))
|
assert.equals('"I have \\\\\\\\ two backslashes"', inspect('I have \\\\ two backslashes'))
|
||||||
assert.equals('"I have \\\\\\n a backslash followed by a newline"', inspect('I have \\\n a backslash followed by a newline'))
|
assert.equals('"I have \\\\\\n a backslash followed by a newline"', inspect('I have \\\n a backslash followed by a newline'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
@ -320,7 +320,7 @@ describe( 'inspect', function()
|
|||||||
}, items)
|
}, items)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('handles recursive tables correctly', function()
|
it('handles recursive tables correctly', function()
|
||||||
local tbl = { 1,2,3}
|
local tbl = { 1,2,3}
|
||||||
tbl.loop = tbl
|
tbl.loop = tbl
|
||||||
@ -425,10 +425,10 @@ describe( 'inspect', function()
|
|||||||
|
|
||||||
it('allows changing the global tostring', function()
|
it('allows changing the global tostring', function()
|
||||||
local save = _G.tostring
|
local save = _G.tostring
|
||||||
_G.tostring = inspect
|
_G.tostring = inspect
|
||||||
local s = tostring({1, 2, 3})
|
local s = tostring({1, 2, 3})
|
||||||
_G.tostring = save
|
_G.tostring = save
|
||||||
assert.equals("{ 1, 2, 3 }", s)
|
assert.equals("{ 1, 2, 3 }", s)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user