Make table.isempty work with table which has a key as false (Baiyan Huang)

This commit is contained in:
Jason Perkins 2013-07-29 11:41:05 -04:00
parent b3fdb1457d
commit 347f10a379
2 changed files with 12 additions and 5 deletions

View File

@ -224,7 +224,7 @@
-- --
function table.isempty(t) function table.isempty(t)
return not next(t) return next(t) == nil
end end

View File

@ -1,12 +1,11 @@
-- --
-- tests/base/test_table.lua -- tests/base/test_table.lua
-- Automated test suite for the new table functions. -- Automated test suite for the new table functions.
-- Copyright (c) 2008-2010 Jason Perkins and the Premake project -- Copyright (c) 2008-2013 Jason Perkins and the Premake project
-- --
T.table = { } local suite = test.declare("table")
local suite = T.table
local t local t
@ -67,3 +66,11 @@
function suite.isempty_ReturnsFalseOnNotEmpty() function suite.isempty_ReturnsFalseOnNotEmpty()
test.isfalse(table.isempty({ 1 })) test.isfalse(table.isempty({ 1 }))
end end
function suite.isempty_ReturnsFalseOnNotEmptyMap()
test.isfalse(table.isempty({ name = 'premake' }))
end
function suite.isempty_ReturnsFalseOnNotEmptyMapWithFalseKey()
test.isfalse(table.isempty({ [false] = 0 }))
end