Module:HashUtil/testcases

local Hash = require 'Module:HashUtil' local suite = require 'Module:ScribuntoUnit':new

function suite:test_remove local t = {'a', 'b', key = 'value'}

suite:assertEquals('a', Hash.remove(t, 1)) suite:assertEquals(nil, t[1]) suite:assertEquals('b', t[2]) suite:assertEquals(nil, Hash.remove(t, 1))

suite:assertEquals('b', Hash.remove(t, 2)) suite:assertEquals(nil, t[2])

suite:assertEquals('value', Hash.remove(t, 'key')) suite:assertEquals(nil, next(t)) end

return suite