Skip to content

Commit 445b298

Browse files
committed
additional table tests
1 parent 5ab3dc7 commit 445b298

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/tables/main.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ local mt =
2020
__len = function() return 42 end,
2121
__add = function(self, other) return make() end,
2222
__tostring = function() return "foobar" end,
23+
__metatable = "hidden"
2324
}
2425

2526
make = function()
2627
return setmetatable({}, mt)
2728
end
2829

30+
local empty = {}
31+
local emptyWithMt = setmetatable({}, {__index = {foo = "FOO"}})
32+
local emptyWithLenMt = setmetatable({}, {__len = function() return 42 end})
33+
local emptyWithBadLenMt = setmetatable({}, {__len = function() error("FUBAR") end})
34+
local emptyWithBadIndexMt = setmetatable({}, {__index = function(s, k) error("FUBAR") end})
35+
2936
local a = make()
3037
local b = make()
3138
print(#a) --0 in 5.1/jit, 42 in 5.2+

0 commit comments

Comments
 (0)