Skip to content

Commit

Permalink
verify expected results
Browse files Browse the repository at this point in the history
  • Loading branch information
Tieske committed Nov 6, 2024
1 parent 9a8d1b1 commit 5f94f1f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/test-types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ asserteq(types.is_callable(List),true)
do
local mt = setmetatable({}, {
__index = {
__call = function() end
__call = function() return "ok" end
}
})
asserteq(type(mt.__call), "function") -- __call is looked-up through another metatable
local nc = setmetatable({}, mt)
-- proof-of-pudding, let's call it. To verify Lua behaves the same on all engines
local success, result = pcall(function() return nc() end)
assert(result ~= "ok", "expected result to not be 'ok'")
asserteq(success, false)
-- real test now
asserteq(types.is_callable(nc), false) -- NOT callable, since __call is fetched using RAWget by Lua
end

Expand Down

0 comments on commit 5f94f1f

Please sign in to comment.