mirror of
https://github.com/TangentFoxy/inspect.lua.git
synced 2025-07-28 02:52:18 +00:00
extend filter with a path parameter. Fixes #12
This commit is contained in:
@@ -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 = {}
|
||||
|
Reference in New Issue
Block a user