Skip to content

Commit

Permalink
some function environment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ferronn-dev committed Sep 4, 2024
1 parent 034734a commit a2d702e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions spec/flatdump_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,40 @@ describe('flatdump', function()
}
assert.same(expected, flatdump(input))
end)

it('handles function environments', function()
local input = setfenv(function() end, { foo = 'bar' })
local expected = {
[1] = {
e = 't2',
},
[2] = {
sfoo = 'sbar',
},
}
assert.same(expected, flatdump(input))
end)

it('handles function environments on nested table entry', function()
local input = {
outer = {
inner = setfenv(function() end, { foo = 'bar' }),
},
}
local expected = {
[1] = {
souter = 't2',
},
[2] = {
sinner = 'f3',
},
[3] = {
e = 't4',
},
[4] = {
sfoo = 'sbar',
},
}
assert.same(expected, flatdump(input))
end)
end)

0 comments on commit a2d702e

Please sign in to comment.