Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomif committed Nov 30, 2016
2 parents 0497e29 + 0b17e3e commit 042a151
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/IO/All.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strict; use warnings;
package IO::All;
our $VERSION = '0.86';
our $VERSION = '0.86.1';

require Carp;
# So one can use Carp::carp "$message" - without the parenthesis.
Expand Down Expand Up @@ -155,6 +155,7 @@ use overload '<<' => '_overload_left_bitshift';
use overload '>>' => '_overload_right_bitshift';
use overload '<' => '_overload_less_than';
use overload '>' => '_overload_greater_than';
use overload 'cmp' => '_overload_cmp';
use overload '${}' => '_overload_string_deref';
use overload '@{}' => '_overload_array_deref';
use overload '%{}' => '_overload_hash_deref';
Expand Down Expand Up @@ -244,6 +245,13 @@ sub _get_argument_type {
return $argument->type || 'unknown';
}

sub _overload_cmp {
my ($self, $other, $swap) = @_;
$self = defined($self) ? $self.'' : $self;
($self, $other) = ($other, $self) if $swap;
$self cmp $other;
}

sub _overload_stringify {
my $self = shift;
my $name = $self->pathname;
Expand Down
6 changes: 5 additions & 1 deletion test/overload.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strict; use warnings;
my $t; use lib ($t = -e 't' ? 't' : 'test');
use Test::More tests => 24;
use Test::More tests => 26;
use IO_All_Test;
use IO::All;

Expand Down Expand Up @@ -86,5 +86,9 @@ test_file_contents2(o_dir() . '/overload1', $cat3);
is "" . ${io($t)}, $t, "scalar overload of directory (for mst)";
#because it broke lots of modules via File::Spec::Win32::catfile/catdir
my ($f1,$f2) = io->dir( o_dir() )->all;
ok $f1 ne "", 'string operations overload';
ok $f1 cmp $f2, 'string operations overload';
del_output_dir();

0 comments on commit 042a151

Please sign in to comment.