Subject: | List::Util::sum doesn't respect overloading |
If you make the following modification to sum.t, p_sum.t passes, but sum.t doesn't get the
right sum.
--- Scalar-List-Utils-1.22/t/sum.t 2009-05-13 17:59:43.000000000 -0400
+++ Scalar-List-Utils-1.22_mod/t/sum.t 2010-01-25 10:28:26.000000000 -0500
@@ -13,7 +13,7 @@
}
}
-use Test::More tests => 8;
+use Test::More tests => 9;
use List::Util qw(sum);
@@ -43,13 +43,14 @@
$v = sum($one,$two,$thr);
is($v, 6, 'overload');
-
+isa_ok( $v, 'Foo' );
{ package Foo;
use overload
'""' => sub { ${$_[0]} },
'+0' => sub { ${$_[0]} },
+ '+' => sub { ref($_[0])->new( ${$_[0]} + ($_[1] + 0) ) },
fallback => 1;
sub new {
my $class = shift;