Depth control also working on keys

eLua
Enrique García Cota 14 years ago
parent 4572d02f72
commit 80feaaf4d0
  1. 48
      spec/inspect_spec.lua

@ -77,34 +77,56 @@ context( 'inspect', function()
}]]) }]])
end) end)
test('Should respect depth', function() context('depth', function()
local level4 = { 1,2,3, a = { b = { c = { d = 4 } } } } local level5 = { 1,2,3, a = { b = { c = { d = { e = 5 } } } } }
assert_equal(inspect(level4, 4), [[{ 1, 2, 3, local keys = { [level5] = true }
test('Should have a default depth of 4', function()
assert_equal(inspect(level5), [[{ 1, 2, 3,
a = { a = {
b = { b = {
c = { c = {
d = 4 d = {...}
} }
} }
} }
}]]) }]])
assert_equal(inspect(level4, 3), [[{ 1, 2, 3, end)
test('Should be modifiable by the user', function()
assert_equal(inspect(level5, 2), [[{ 1, 2, 3,
a = { a = {
b = { b = {...}
c = {...}
}
} }
}]]) }]])
assert_equal(inspect(level4, 2), [[{ 1, 2, 3, assert_equal(inspect(level5, 1), [[{ 1, 2, 3,
a = {...}
}]])
assert_equal(inspect(level5, 0), "{...}")
assert_equal(inspect(level5, 6), [[{ 1, 2, 3,
a = { a = {
b = {...} b = {
c = {
d = {
e = 5
}
}
}
} }
}]]) }]])
assert_equal(inspect(level4, 1), [[{ 1, 2, 3, end)
a = {...}
}]])
test('Should respect depth on keys', function()
assert_equal(inspect(keys), [[{
[{ 1, 2, 3,
a = {
b = {
c = {...}
}
}
}] = true
}]])
end)
end) end)

Loading…
Cancel
Save