Added lume.first() and .last(), updated README.md and tests

This commit is contained in:
rxi
2014-12-12 21:33:41 +00:00
parent de37bd6d65
commit 8f1267f967
3 changed files with 42 additions and 0 deletions

View File

@@ -266,6 +266,22 @@ tests["lume.slice"] = function()
testeq( lume.slice({"a", "b", "c", "d", "e"}, -3, 900), {"c", "d", "e"} )
end
-- lume.first
tests["lume.first"] = function()
local t = { "a", "b", "c", "d", "e" }
testeq( lume.first(t), "a" )
testeq( lume.first(t, 1), { "a" } )
testeq( lume.first(t, 2), { "a", "b" } )
end
-- lume.last
tests["lume.last"] = function()
local t = { "a", "b", "c", "d", "e" }
testeq( lume.last(t), "e" )
testeq( lume.last(t, 1), { "e" } )
testeq( lume.last(t, 2), { "d", "e" } )
end
-- lume.invert
tests["lume.invert"] = function()
testeq( lume.invert({}), {} )