diff options
-rw-r--r-- | lua/inet/init.lua | 4 | ||||
-rw-r--r-- | test/inet.lua | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lua/inet/init.lua b/lua/inet/init.lua index 99d1195..72677f9 100644 --- a/lua/inet/init.lua +++ b/lua/inet/init.lua @@ -18,7 +18,9 @@ function inet.new(ip, mask) end function inet:__len() - return self.mask + local mask = self.mask + if mask == nil then return 0 end -- make metatable inspectable + return mask end local lshift = bit32.lshift diff --git a/test/inet.lua b/test/inet.lua index e86c074..22f7185 100644 --- a/test/inet.lua +++ b/test/inet.lua @@ -114,6 +114,9 @@ return test.new(function() end end + -- test inspectablity of metatable + assert(#(getmetatable(inet('::/0'))) ~= nil) + -- TODO inet6.__le -- TODO inet6.__eq end) |