[Moose-commits] r7401 - in Moose-Autobox/trunk: lib/Moose/Autobox t

sartak at code2.0beta.co.uk sartak at code2.0beta.co.uk
Wed Jan 28 07:51:48 GMT 2009


Author: sartak
Date: 2009-01-27 23:51:48 -0800 (Tue, 27 Jan 2009)
New Revision: 7401

Modified:
   Moose-Autobox/trunk/lib/Moose/Autobox/String.pm
   Moose-Autobox/trunk/t/005_string.t
Log:
Return list references from words, lines, and split for maximal autobox
goodness

Modified: Moose-Autobox/trunk/lib/Moose/Autobox/String.pm
===================================================================
--- Moose-Autobox/trunk/lib/Moose/Autobox/String.pm	2009-01-28 07:21:12 UTC (rev 7400)
+++ Moose-Autobox/trunk/lib/Moose/Autobox/String.pm	2009-01-28 07:51:48 UTC (rev 7401)
@@ -15,8 +15,8 @@
 sub chop    { CORE::chop    $_[0] }
 sub reverse { CORE::reverse $_[0] }
 sub length  { CORE::length  $_[0] }
-sub lines   { CORE::split '\n', $_[0] }
-sub words   { CORE::split ' ',  $_[0] }
+sub lines   { [ CORE::split '\n', $_[0] ] }
+sub words   { [ CORE::split ' ',  $_[0] ] }
 sub index   { 
     return CORE::index($_[0], $_[1]) if scalar @_ == 2;
     return CORE::index($_[0], $_[1], $_[2]);
@@ -26,8 +26,8 @@
     return CORE::rindex($_[0], $_[1], $_[2]);
 }
 sub split   {
-    return CORE::split($_[1], $_[0]) if scalar @_ == 2;
-    return CORE::split($_[1], $_[0], $_[2]);
+    return [ CORE::split($_[1], $_[0]) ] if scalar @_ == 2;
+    return [ CORE::split($_[1], $_[0], $_[2]) ];
 }
 
 1;

Modified: Moose-Autobox/trunk/t/005_string.t
===================================================================
--- Moose-Autobox/trunk/t/005_string.t	2009-01-28 07:21:12 UTC (rev 7400)
+++ Moose-Autobox/trunk/t/005_string.t	2009-01-28 07:51:48 UTC (rev 7401)
@@ -47,9 +47,9 @@
 
 is('Hello World, Hello'->rindex('Hello', 6), 0, '... got the correct right index');
 
-is_deeply(['/foo/bar/baz'->split('/')], ['', 'foo', 'bar', 'baz'], '... got the correct fragments');
-is_deeply(['Hello World'->words], ['Hello', 'World'], '... got the correct words');
-is_deeply(["Hello\nWor\n\nld\n"->lines], ['Hello', 'Wor', '', 'ld'], '... got the correct lines');
+is_deeply('/foo/bar/baz'->split('/'), ['', 'foo', 'bar', 'baz'], '... got the correct fragments');
+is_deeply('Hello World'->words, ['Hello', 'World'], '... got the correct words');
+is_deeply("Hello\nWor\n\nld\n"->lines, ['Hello', 'Wor', '', 'ld'], '... got the correct lines');
 
 eval 'Hello World, Hello'->dump;
 is($VAR1, 'Hello World, Hello' , '... eval of &dump works');




More information about the Moose-commits mailing list