summaryrefslogtreecommitdiff
path: root/lib/overload.t
diff options
context:
space:
mode:
Diffstat (limited to 'lib/overload.t')
-rw-r--r--lib/overload.t18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t
index 44ead7ef60..7c2476cc8c 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 => 556;
+use Test::More tests => 558;
$a = new Oscalar "087";
@@ -1427,4 +1427,20 @@ foreach my $op (qw(<=> == != < <= > >=)) {
is($aref**1, $num_val, 'exponentiation of ref');
}
+{
+ package CopyConstructorFallback;
+ use overload
+ '++' => sub { "$_[0]"; $_[0] },
+ fallback => 1;
+ sub new { bless {} => shift }
+
+ package main;
+
+ my $o = CopyConstructorFallback->new;
+ my $x = $o++; # would segfault
+ my $y = ++$o;
+ is($x, $o, "copy constructor falls back to assignment (postinc)");
+ is($y, $o, "copy constructor falls back to assignment (preinc)");
+}
+
# EOF