This is an automated email from the git hooks/post-receive script. js pushed a commit to branch master in repository libcatmandu-perl.
commit 51babb5add8848a16c3ee8058b891563a67f894e Author: Patrick Hochstenbach <patrick.hochstenb...@ugent.be> Date: Fri Dec 11 16:49:48 2015 +0100 Fixed array_to_sentence bug --- lib/Catmandu/Util.pm | 2 +- t/Catmandu-Util.t | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/Catmandu/Util.pm b/lib/Catmandu/Util.pm index 75cd1a0..75fd3c3 100644 --- a/lib/Catmandu/Util.pm +++ b/lib/Catmandu/Util.pm @@ -308,7 +308,7 @@ sub array_to_sentence { $join_last //= ' and '; my $size = scalar @$arr; $size > 2 - ? join($join_last, join($join, @$arr[0..$size-1]), $arr->[-1]) + ? join($join_last, join($join, @$arr[0..$size-2]), $arr->[-1]) : join($join_last, @$arr); } diff --git a/t/Catmandu-Util.t b/t/Catmandu-Util.t index 6924915..78e3b91 100644 --- a/t/Catmandu-Util.t +++ b/t/Catmandu-Util.t @@ -383,14 +383,41 @@ is Catmandu::Util::array_sum([1,2,3,4,5,6,7,8,9,10]) , 55 , 'array_sum'; ok Catmandu::Util::array_includes([{ foo => [ { bar => 1}]}] , {foo => [ { bar => 1}]} ) , 'array_includes'; +ok ! Catmandu::Util::array_includes([{ foo => [ { bar => 1}]}] , {foo => [ { bar => 5}]} ) , '!array_includes'; + ok Catmandu::Util::array_any([0,1,2], sub { return 1 if shift == 2}) , 'array_any'; +ok ! Catmandu::Util::array_any([0,1,2], sub { return 1 if shift == 100}) , 'array_any'; + +is Catmandu::Util::array_to_sentence([1,2]) , '1 and 2' , 'array_to_sentence'; + +is Catmandu::Util::array_to_sentence([1,2,3]) , '1, 2 and 3' , 'array_to_sentence'; + is_deeply Catmandu::Util::array_rest([0,1,2]) , [1,2] , 'array_rest'; is_deeply Catmandu::Util::array_uniq([0,1,2,2,2,2,3,3,2,3]) , [0,1,2,3] , 'array_uniq'; +is_deeply Catmandu::Util::hash_merge({ a => { b => 1 } } , { a => { c => 2 } }) , { a => { b => 1 , c => 2 } } , 'hash_merge'; + +is Catmandu::Util::as_utf8("école") , "école" , 'as_utf8'; + +is Catmandu::Util::trim(" \r\n bla \t\t\t\r\n") , "bla" , 'trim'; + is Catmandu::Util::capitalize("école") , "École" , 'capitalize'; +ok Catmandu::Util::is_same({ a => [ { b => 1 , c => 1 }]} , { a => [ { c => 1 , b => 1 }]}) , 'is_same'; + +ok Catmandu::Util::is_different({ a => [ { b => 1 , c => 1 }]} , { a => [ { d => 1 , b => 1 }]}) , 'is_different'; + +ok Catmandu::Util::check_same({ a => [ { b => 1 , c => 1 }]} , { a => [ { c => 1 , b => 1 }]}) , 'check_same'; + +throws_ok { Catmandu::Util::check_same({ a => [ { b => 1 , c => 1 }]} , { a => [ { d => 1 , b => 1 }]}) } 'Catmandu::BadVal' , '!check_same'; + +ok Catmandu::Util::check_different({ a => [ { b => 1 , c => 1 }]} , { a => [ { b => 1 , b => 1 }]}) , 'check_different'; + +throws_ok { Catmandu::Util::check_different({ a => [ { b => 1 , c => 1 }]} , { a => [ { c => 1 , b => 1 }]}) } 'Catmandu::BadVal' , '!check_different'; + + is Catmandu::Util::human_number(64354) , "64,354" , 'human_number'; is Catmandu::Util::human_byte_size(10) , "10 bytes" , 'human_byte_size'; @@ -404,4 +431,4 @@ is Catmandu::Util::xml_declaration() , qq(<?xml version="1.0" encoding="UTF-8"?> is Catmandu::Util::xml_escape("<>'&") , '<>'&' , 'xml_escape'; -done_testing 534; \ No newline at end of file +done_testing 547; \ No newline at end of file -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits