From: Anders Nor Berle Date: Wed, 11 Apr 2007 06:02:16 +0000 (+0000) Subject: Make rindex work. X-Git-Tag: 0_04~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dae37220e3b67801c5ca7d4dce13ed0b7ad4621a;p=gitmo%2FMoose-Autobox.git Make rindex work. --- diff --git a/lib/Moose/Autobox/String.pm b/lib/Moose/Autobox/String.pm index 69bc977..88b1bf4 100644 --- a/lib/Moose/Autobox/String.pm +++ b/lib/Moose/Autobox/String.pm @@ -1,7 +1,7 @@ package Moose::Autobox::String; use Moose::Role; -our $VERSION = '0.01'; +our $VERSION = '0.02'; with 'Moose::Autobox::Value'; @@ -19,10 +19,11 @@ sub index { return CORE::index($_[0], $_[1]) if scalar @_ == 2; return CORE::index($_[0], $_[1], $_[2]); } +sub rindex { + return CORE::rindex($_[0], $_[1]) if scalar @_ == 2; + return CORE::rindex($_[0], $_[1], $_[2]); +} -# FIXME: this is not working -#sub rindex { CORE::rindex $_[0], $_[1], (defined $_[2] ? $_[2] : ()) } - 1; __END__ @@ -61,6 +62,8 @@ This is a role to describes a String value. =item B +=item B + =item B =item B @@ -83,6 +86,8 @@ to cpan-RT. Stevan Little Estevan@iinteractive.comE +Anders Nor Berle Edebolaz@gmail.comE + =head1 COPYRIGHT AND LICENSE Copyright 2006 by Infinity Interactive, Inc. @@ -92,4 +97,5 @@ L This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. -=cut \ No newline at end of file +=cut + diff --git a/t/005_string.t b/t/005_string.t index 086ef26..bdba48f 100644 --- a/t/005_string.t +++ b/t/005_string.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 16; +use Test::More tests => 18; use Test::Exception; BEGIN { @@ -41,5 +41,7 @@ is('Hello World, Hello'->index('Hello'), 0, '... got the correct index'); is('Hello World, Hello'->index('Hello', 6), 13, '... got the correct index'); -#is('Hello World, Hello'->rindex('World'), 13, '... got the correct right index'); -#diag CORE::rindex('Hello World, Hello', 'Hello'); +is('Hello World, Hello'->rindex('Hello'), 13, '... got the correct right index'); + +is('Hello World, Hello'->rindex('Hello', 6), 0, '... got the correct right index'); +