summaryrefslogtreecommitdiff
path: root/lib/overload.t
diff options
context:
space:
mode:
Diffstat (limited to 'lib/overload.t')
-rw-r--r--lib/overload.t27
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/overload.t b/lib/overload.t
index 29411e1a4b..94cd296b44 100644
--- a/lib/overload.t
+++ b/lib/overload.t
@@ -47,7 +47,7 @@ sub numify { 0 + "${$_[0]}" } # Not needed, additional overhead
package main;
$| = 1;
-use Test::More tests => 536;
+use Test::More tests => 556;
$a = new Oscalar "087";
@@ -1384,7 +1384,7 @@ foreach my $op (qw(<=> == != < <= > >=)) {
package numify_other;
use overload "0+" => sub { $_[0][0]++; $_[0][1] = bless [], 'numify_int' };
package numify_by_fallback;
- use overload "-" => sub { 1 }, fallback => 1;
+ use overload fallback => 1;
package main;
my $o = bless [], 'numify_int';
@@ -1404,4 +1404,27 @@ foreach my $op (qw(<=> == != < <= > >=)) {
my $m = bless $aref, 'numify_by_fallback';
is(int($m), $num_val, 'numifies to usual reference value');
+ is(abs($m), $num_val, 'numifies to usual reference value');
+ is(-$m, -$num_val, 'numifies to usual reference value');
+ is(0+$m, $num_val, 'numifies to usual reference value');
+ is($m+0, $num_val, 'numifies to usual reference value');
+ is($m+$m, 2*$num_val, 'numifies to usual reference value');
+ is(0-$m, -$num_val, 'numifies to usual reference value');
+ is(1*$m, $num_val, 'numifies to usual reference value');
+ is($m/1, $num_val, 'numifies to usual reference value');
+ is($m%100, $num_val%100, 'numifies to usual reference value');
+ is($m**1, $num_val, 'numifies to usual reference value');
+
+ is(abs($aref), $num_val, 'abs() of ref');
+ is(-$aref, -$num_val, 'negative of ref');
+ is(0+$aref, $num_val, 'ref addition');
+ is($aref+0, $num_val, 'ref addition');
+ is($aref+$aref, 2*$num_val, 'ref addition');
+ is(0-$aref, -$num_val, 'subtraction of ref');
+ is(1*$aref, $num_val, 'multiplicaton of ref');
+ is($aref/1, $num_val, 'division of ref');
+ is($aref%100, $num_val%100, 'modulo of ref');
+ is($aref**1, $num_val, 'exponentiation of ref');
}
+
+# EOF