summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2012-06-29 00:38:04 -0500
committerJesse Luehrs <doy@tozt.net>2012-06-29 00:46:57 -0500
commit386a54892347d3298ba7f1e98f207e36bc4f3424 (patch)
tree9aa57403efdddc7d93295f6365c7e9a34142ba8f /lib
parentaf41786fe5732d5ec7932b946eec99a695ac6e43 (diff)
downloadperl-386a54892347d3298ba7f1e98f207e36bc4f3424.tar.gz
"use overload fallback => 0" should enable overloading [perl #113010]
This makes package Foo; use overload fallback => 0; and package Bar; use overload '+' => \&add, fallback => 0; behave identically when an operator other than '+' is used.
Diffstat (limited to 'lib')
-rw-r--r--lib/overload.t14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/overload.t b/lib/overload.t
index a1324923c3..5212083b8b 100644
--- a/lib/overload.t
+++ b/lib/overload.t
@@ -48,7 +48,7 @@ package main;
$| = 1;
BEGIN { require './test.pl' }
-plan tests => 5184;
+plan tests => 5186;
use Scalar::Util qw(tainted);
@@ -2627,6 +2627,18 @@ is eval {"$a"}, overload::StrVal($a), 'fallback is stored under "()"';
is($obj->val, 7, "correct result (add incr void)");
}
+# [perl #113010]
+{
+ {
+ package OnlyFallback;
+ use overload fallback => 0;
+ }
+ my $obj = bless {}, 'OnlyFallback';
+ my $died = !eval { "".$obj; 1 };
+ my $err = $@;
+ ok($died, "fallback of 0 causes error");
+ like($err, qr/"\.": no method found/, "correct error");
+}
{ # undefining the overload stash -- KEEP THIS TEST LAST
package ant;