made depth default to infinite

This commit is contained in:
kikito 2012-10-29 23:32:44 +01:00
parent b744b7f3f8
commit 78c4643ba0
2 changed files with 8 additions and 9 deletions

View File

@ -148,7 +148,7 @@ end
function Inspector:putTable(t)
if self:alreadyVisited(t) then
self:puts('<table ', self:getId(t), '>')
elseif self.level >= self.depth then
elseif self.depth and self.level >= self.depth then
self:puts('{...}')
else
if self.tableAppearances[t] > 1 then
@ -232,7 +232,6 @@ function Inspector:putKey(k)
end
local function inspect(t, depth)
depth = depth or 4
return tostring(Inspector:new(t, depth))
end

View File

@ -96,12 +96,14 @@ context( 'inspect', function()
local level5 = { 1,2,3, a = { b = { c = { d = { e = 5 } } } } }
local keys = { [level5] = true }
it('has a default depth of 4', function()
it('has infinite depth by default', function()
assert_equal(inspect(level5), [[{ 1, 2, 3,
a = {
b = {
c = {
d = {...}
d = {
e = 5
}
}
}
}
@ -117,13 +119,11 @@ context( 'inspect', function()
a = {...}
}]])
assert_equal(inspect(level5, 0), "{...}")
assert_equal(inspect(level5, 6), [[{ 1, 2, 3,
assert_equal(inspect(level5, 4), [[{ 1, 2, 3,
a = {
b = {
c = {
d = {
e = 5
}
d = {...}
}
}
}
@ -132,7 +132,7 @@ context( 'inspect', function()
end)
it('respects depth on keys', function()
assert_equal(inspect(keys), [[{
assert_equal(inspect(keys, 4), [[{
[{ 1, 2, 3,
a = {
b = {