1-- 2-- tests/base/test_table.lua 3-- Automated test suite for the new table functions. 4-- Copyright (c) 2008-2010 Jason Perkins and the Premake project 5-- 6 7 8 T.table = { } 9 local suite = T.table 10 11 12-- 13-- table.contains() tests 14-- 15 16 function suite.contains_OnContained() 17 t = { "one", "two", "three" } 18 test.istrue( table.contains(t, "two") ) 19 end 20 21 function suite.contains_OnNotContained() 22 t = { "one", "two", "three" } 23 test.isfalse( table.contains(t, "four") ) 24 end 25 26 27-- 28-- table.flatten() tests 29-- 30 31 function suite.flatten_OnMixedValues() 32 t = { "a", { "b", "c" }, "d" } 33 test.isequal({ "a", "b", "c", "d" }, table.flatten(t)) 34 end 35 36 37-- 38-- table.implode() tests 39-- 40 41 function suite.implode() 42 t = { "one", "two", "three", "four" } 43 test.isequal("[one], [two], [three], [four]", table.implode(t, "[", "]", ", ")) 44 end 45 46 47-- 48-- table.isempty() tests 49-- 50 51 function suite.isempty_ReturnsTrueOnEmpty() 52 test.istrue(table.isempty({})) 53 end 54 55 function suite.isempty_ReturnsFalseOnNotEmpty() 56 test.isfalse(table.isempty({ 1 })) 57 end 58