Depth control also working on keys

This commit is contained in:
Enrique García Cota 2011-04-24 01:02:05 +02:00
parent 4572d02f72
commit 80feaaf4d0

View File

@ -77,34 +77,56 @@ context( 'inspect', function()
}]])
end)
test('Should respect depth', function()
local level4 = { 1,2,3, a = { b = { c = { d = 4 } } } }
assert_equal(inspect(level4, 4), [[{ 1, 2, 3,
context('depth', function()
local level5 = { 1,2,3, a = { b = { c = { d = { e = 5 } } } } }
local keys = { [level5] = true }
test('Should have a default depth of 4', function()
assert_equal(inspect(level5), [[{ 1, 2, 3,
a = {
b = {
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 = {
b = {...}
}
}]])
assert_equal(inspect(level5, 1), [[{ 1, 2, 3,
a = {...}
}]])
assert_equal(inspect(level5, 0), "{...}")
assert_equal(inspect(level5, 6), [[{ 1, 2, 3,
a = {
b = {
c = {
d = {
e = 5
}
}
}
}
}]])
end)
test('Should respect depth on keys', function()
assert_equal(inspect(keys), [[{
[{ 1, 2, 3,
a = {
b = {
c = {...}
}
}
}] = true
}]])
assert_equal(inspect(level4, 2), [[{ 1, 2, 3,
a = {
b = {...}
}
}]])
assert_equal(inspect(level4, 1), [[{ 1, 2, 3,
a = {...}
}]])
end)
end)