diff options
author | steve donovan <steve.j.donovan@gmail.com> | 2011-09-30 16:38:29 +0400 |
---|---|---|
committer | steve donovan <steve.j.donovan@gmail.com> | 2011-09-30 16:38:29 +0400 |
commit | d2e357ba30210fd341918ece9ab8c89a7abe8642 (patch) | |
tree | cf78d93ac8f54cfbb55b08216062799d73d684c1 /tests/test-pylib.lua | |
parent | abe15bf5ebe162fe1d19334f793558881b926606 (diff) |
List.range can take extra increment (can be less than 1)
Diffstat (limited to 'tests/test-pylib.lua')
-rw-r--r-- | tests/test-pylib.lua | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/tests/test-pylib.lua b/tests/test-pylib.lua index c2562c3..7ef3388 100644 --- a/tests/test-pylib.lua +++ b/tests/test-pylib.lua @@ -1,8 +1,9 @@ -- test-pylib.lua local List = require 'pl.List' require 'pl.stringx'.import() -local text = require ('pl.text') +local text = require 'pl.text' local Template = text.Template +local asserteq = require 'pl.test' . asserteq l = List{10,20,30,40,50} s = List{1,2,3,4,5} @@ -25,15 +26,20 @@ assert (lst[#lst] == 10) assert (lst[#lst-2] == 20) lst = List {10,20,30,40,50} -assert (lst:slice(2) == List{20,30,40,50}) -assert (lst:slice(-2) == List{40,50}) -assert (lst:slice(nil,3) == List{10,20,30}) -assert (lst:slice(2,4) == List{20,30,40}) -assert (lst:slice(-4,-2) == List{20,30,40}) +asserteq (lst:slice(2),{20,30,40,50}) +asserteq (lst:slice(-2),{40,50}) +asserteq (lst:slice(nil,3),{10,20,30}) +asserteq (lst:slice(2,4),{20,30,40}) +asserteq (lst:slice(-4,-2),{20,30,40}) + lst = List.range(0,9) seq = List{0,1,2,3,4,5,6,7,8,9} +asserteq(List.range(0,8,2),{0,2,4,6,8}) +asserteq(tostring(List.range(0,1,0.2)),'{0,0.2,0.4,0.6,0.8,1}') + + assert(lst == seq) -assert (List('abcd') == List{'a','b','c','d'}) +asserteq (List('abcd'),List{'a','b','c','d'}) ls = List{10,20,30,40} ls:slice_assign(2,3,{21,31}) assert (ls == List{10,21,31,40}) |