extend filter with a path parameter. Fixes #12

This commit is contained in:
kikito
2014-02-09 18:42:38 +01:00
parent b718a2e55c
commit a2ccd9220c
2 changed files with 32 additions and 9 deletions

View File

@@ -216,6 +216,22 @@ describe( 'inspect', function()
end)
it('filters by path', function()
local people = { tony = { age = 21 }, martha = { age = 34} }
local hideMarthaAge = function(_,path)
return table.concat(path, '.') == 'martha.age'
end
assert.equals(inspect(people, {filter = hideMarthaAge}), [[{
martha = {
age = <filtered>
},
tony = {
age = 21
}
}]])
end)
it('does not increase the table ids', function()
local a = {'this is a'}
local b = {}