Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added test for split.t. Wasn't returning a list in list context, fixe…

…d it.
  • Loading branch information...
commit a910dbd3700c671e4f10888d0311649bac12c62e 1 parent 5b47268
@brunoV brunoV authored
Showing with 13 additions and 1 deletion.
  1. +1 −1  Core.pm
  2. +12 −0 t/split.t
View
2  Core.pm
@@ -665,7 +665,7 @@ sub undef ($) { $_[0] = undef }
sub m ($$) { [ $_[0] =~ m{$_[1]} ] }
sub nm ($$) { [ $_[0] !~ m{$_[1]} ] }
sub s ($$$) { $_[0] =~ s{$_[1]}{$_[2]} }
-sub split ($$) { [ split $_[1], $_[0] ] }
+sub split ($$) { wantarray ? split $_[1], $_[0] : [ split $_[1], $_[0] ] }
sub eval ($) { CORE::eval "$_[0]"; }
sub system ($;@) { CORE::system @_; }
View
12 t/split.t
@@ -0,0 +1,12 @@
+use Test::More qw(no_plan);
+use strict;
+use warnings;
+
+use autobox::Core;
+
+is_deeply ["hi there"->split(qr/ */)], [qw(h i t h e r e)];
+
+my $arrayref = "hi there"->split(qr/ */);
+
+is ref $arrayref, 'ARRAY', "Returns arrayref in scalar context";
+
Please sign in to comment.
Something went wrong with that request. Please try again.