mirror of
https://github.com/TangentFoxy/lume.git
synced 2024-11-19 07:04:24 +00:00
Added lume.clear() and tests
This commit is contained in:
parent
14b9ee0ca2
commit
fa85f83d70
8
lume.lua
8
lume.lua
@ -175,6 +175,14 @@ function lume.remove(t, x)
|
||||
end
|
||||
|
||||
|
||||
function lume.clear(t)
|
||||
local iter = getiter(t)
|
||||
for k, v in iter(t) do
|
||||
t[k] = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function lume.shuffle(t)
|
||||
local rtn = {}
|
||||
for i = 1, #t do
|
||||
|
@ -129,6 +129,16 @@ tests["lume.remove"] = function()
|
||||
local m = { a = 1, b = 2, c = 3 }
|
||||
end
|
||||
|
||||
-- lume.clear
|
||||
tests["lume.clear"] = function()
|
||||
local t = { 1, 2, 3 }
|
||||
lume.clear(t)
|
||||
testeq(t, {})
|
||||
local m = { a = 1, b = 2, c = 3 }
|
||||
lume.clear(m)
|
||||
testeq(m, {})
|
||||
end
|
||||
|
||||
-- lume.shuffle
|
||||
tests["lume.shuffle"] = function()
|
||||
local t = {1, 2, 3, 4, 5}
|
||||
|
Loading…
Reference in New Issue
Block a user