Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stevedonovan/Penlight.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsteve donovan <steve.j.donovan@gmail.com>2011-07-04 20:19:42 +0400
committersteve donovan <steve.j.donovan@gmail.com>2011-07-04 20:19:42 +0400
commit8d1ae5837e7d071c839238001441c4d29004701d (patch)
tree889fd8a75a5a286a3e38f813ca4cfb52fb5d8fdf /tests/test-pylib.lua
parent7775498f951ace79a1f38f0f0eff31b61632df2a (diff)
added stringx.title
Diffstat (limited to 'tests/test-pylib.lua')
-rw-r--r--tests/test-pylib.lua114
1 files changed, 58 insertions, 56 deletions
diff --git a/tests/test-pylib.lua b/tests/test-pylib.lua
index d0f6570..d96abdf 100644
--- a/tests/test-pylib.lua
+++ b/tests/test-pylib.lua
@@ -1,56 +1,58 @@
--- test-pylib.lua
-local List = require 'pl.List'
-require 'pl.stringx'.import()
-local text = require ('pl.text')
-local Template = text.Template
-
-l = List{10,20,30,40,50}
-s = List{1,2,3,4,5}
-
--- test using: lua pylist.lua
-local lst = List:new()
-lst:append(10)
-lst:extend{20,30,40,50}
-assert (lst == List{10,20,30,40,50})
-lst:insert(3,11)
-lst:remove_value(40)
-assert (lst == List{10,20,11,30,50})
-local q=lst:pop()
-assert( lst:index(30)==4 )
-assert( lst:count(10)==1 )
-lst:sort()
-lst:reverse()
-assert (lst == List{30,20,11,10})
-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})
-lst = List.range(0,9)
-seq = List{0,1,2,3,4,5,6,7,8,9}
-assert(lst == seq)
-assert (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})
--- strings ---
-s = '123'
-assert (s:isdigit())
-assert (not s:isspace())
-s = 'here the dog is just a dog'
-assert (s:startswith('here'))
-assert (s:endswith('dog'))
-assert (s:count('dog') == 2)
-s = ' here we go '
-assert (s:lstrip() == 'here we go ')
-assert (s:rstrip() == ' here we go')
-assert (s:strip() == 'here we go')
-assert (('hello'):center(20,'+') == '++++++++hello+++++++')
-
-t = Template('${here} is the $answer')
-assert(t:substitute {here = 'one', answer = 'two'} == 'one is the two')
-
+-- test-pylib.lua
+local List = require 'pl.List'
+require 'pl.stringx'.import()
+local text = require ('pl.text')
+local Template = text.Template
+
+l = List{10,20,30,40,50}
+s = List{1,2,3,4,5}
+
+-- test using: lua pylist.lua
+local lst = List:new()
+lst:append(10)
+lst:extend{20,30,40,50}
+assert (lst == List{10,20,30,40,50})
+lst:insert(3,11)
+lst:remove_value(40)
+assert (lst == List{10,20,11,30,50})
+local q=lst:pop()
+assert( lst:index(30)==4 )
+assert( lst:count(10)==1 )
+lst:sort()
+lst:reverse()
+assert (lst == List{30,20,11,10})
+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})
+lst = List.range(0,9)
+seq = List{0,1,2,3,4,5,6,7,8,9}
+assert(lst == seq)
+assert (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})
+-- strings ---
+s = '123'
+assert (s:isdigit())
+assert (not s:isspace())
+s = 'here the dog is just a dog'
+assert (s:startswith('here'))
+assert (s:endswith('dog'))
+assert (s:count('dog') == 2)
+s = ' here we go '
+assert (s:lstrip() == 'here we go ')
+assert (s:rstrip() == ' here we go')
+assert (s:strip() == 'here we go')
+assert (('hello'):center(20,'+') == '++++++++hello+++++++')
+
+t = Template('${here} is the $answer')
+assert(t:substitute {here = 'one', answer = 'two'} == 'one is the two')
+
+assert (('hello dolly'):title() == 'Hello Dolly')
+assert (('h bk bonzo TOK fred m'):title() == 'H Bk Bonzo TOK Fred M')