mirror of
https://github.com/TangentFoxy/lume.git
synced 2025-07-28 11:02:20 +00:00
Added new tests for lume.reduce()
This commit is contained in:
@@ -150,8 +150,14 @@ end
|
|||||||
-- lume.reduce
|
-- lume.reduce
|
||||||
tests["lume.reduce"] = function()
|
tests["lume.reduce"] = function()
|
||||||
local concat = function(a, b) return a .. b end
|
local concat = function(a, b) return a .. b end
|
||||||
|
local add = function(a, b) return a + b end
|
||||||
testeq( lume.reduce({"cat", "dog"}, concat, ""), "catdog" )
|
testeq( lume.reduce({"cat", "dog"}, concat, ""), "catdog" )
|
||||||
testeq( lume.reduce({"cat", "dog"}, concat, "pig"), "pigcatdog" )
|
testeq( lume.reduce({"cat", "dog"}, concat, "pig"), "pigcatdog" )
|
||||||
|
testeq( lume.reduce({"me", "ow"}, concat), "meow" )
|
||||||
|
testeq( lume.reduce({1, 2, 3, 4}, add), 10 )
|
||||||
|
testeq( lume.reduce({1, 2, 3, 4}, add), 10 )
|
||||||
|
testeq( lume.reduce({1}, add), 1 )
|
||||||
|
testeq( lume.reduce({}, concat, "potato"), "potato" )
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lume.set
|
-- lume.set
|
||||||
|
Reference in New Issue
Block a user