From: Florian Ragwitz Date: Sat, 29 May 2010 02:09:52 +0000 (+0200) Subject: Add sprintf to String X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fheads%2Ftopic%2Fstring_sprintf;p=gitmo%2FMoose-Autobox.git Add sprintf to String --- diff --git a/Changes b/Changes index ac2e8fd..d624526 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Perl extension Moose::Autobox + - Add sprintf to String (Florian Ragwitz) + 0.11 Fri. Mar 23, 2010 - add each_n_values to Indexed (rafl and rjbs) - add first and last to Scalar and Array (t0m) diff --git a/lib/Moose/Autobox/String.pm b/lib/Moose/Autobox/String.pm index d814c03..8f3579c 100644 --- a/lib/Moose/Autobox/String.pm +++ b/lib/Moose/Autobox/String.pm @@ -15,6 +15,7 @@ sub chomp { CORE::chomp $_[0] } sub chop { CORE::chop $_[0] } sub reverse { CORE::reverse $_[0] } sub length { CORE::length $_[0] } +sub sprintf { CORE::sprintf $_[0], @_[1..$#_] } sub lines { [ CORE::split '\n', $_[0] ] } sub words { [ CORE::split ' ', $_[0] ] } sub index { diff --git a/t/005_string.t b/t/005_string.t index e296653..a4e7894 100644 --- a/t/005_string.t +++ b/t/005_string.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 23; +use Test::More; use Test::Exception; BEGIN { @@ -57,3 +57,6 @@ is($VAR1, 'Hello World, Hello' , '... eval of &dump works'); eval 'Hello World, Hello'->perl; is($VAR1, 'Hello World, Hello' , '... eval of &perl works'); +is('%s %03d'->sprintf(qw(foo 42)), 'foo 042', '... sprintf works'); + +done_testing;