Module:TableTools/testcases
Appearance
![]() | This is the test cases page for the module Module:TableTools. Results of the test cases. |
-- Unit tests for [[Module:TableTools]]. Click talk page to run tests.
local tt = require('Module:TableTools') -- the module to be tested
local ScribuntoUnit = require('Module:ScribuntoUnit')
local suite = ScribuntoUnit:new()
local sparseArray = {1, nil, [1.5] = 1.5, 2, nil, 3, nil, [math.huge] = math.huge, foo = 'bar', ['4'] = 'four_string'}
local sparseArrayConcatenated = '123'
function suite.concatIpairs(t)
local ret = ''
for i, v in ipairs(t) do
ret = ret .. tostring(v)
end
return ret
end
function suite:testCompressSparseArray()
local compressedArray = tt.compressSparseArray(sparseArray)
self:assertEquals(sparseArrayConcatenated, suite.concatIpairs(compressedArray))
end
return suite