diff --git a/inspect.lua b/inspect.lua
index 4e06e91..9e95548 100644
--- a/inspect.lua
+++ b/inspect.lua
@@ -148,7 +148,7 @@ end
function Inspector:putTable(t)
if self:alreadyVisited(t) then
self:puts('
')
- 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
diff --git a/spec/inspect_spec.lua b/spec/inspect_spec.lua
index ec558f9..bcd0fe2 100644
--- a/spec/inspect_spec.lua
+++ b/spec/inspect_spec.lua
@@ -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 = {