Geoffrey T. Dairiki [Wed, 5 Aug 2009 00:54:34 +0000 (17:54 -0700)]
Subject: overload::import resets the setting of 'fallback'
Date: Tue, 04 Aug 2009 17:54:34 -0700
From: "Geoffrey T. Dairiki" <dairiki at dairiki.org>
t/lib/mypragma.pm An example user pragma
t/lib/mypragma.t Test the example user pragma
t/lib/no_load.t Test that some modules don't load others
+t/lib/overload_fallback.t Test that using overload 2x in a scope doesn't clobber fallback
t/lib/proxy_constant_subs.t Test that Proxy Constant Subs behave correctly
t/lib/Sans_mypragma.pm Test module for t/lib/mypragma.t
t/lib/strict/refs Tests of "use strict 'refs'" for strict.t
my %arg = @_;
my ($sub, $fb);
$ {$package . "::OVERLOAD"}{dummy}++; # Register with magic by touching.
+ $fb = ${$package . "::()"}; # preserve old fallback value RT#68196
*{$package . "::()"} = \&nil; # Make it findable via fetchmethod.
for (keys %arg) {
if ($_ eq 'fallback') {
--- /dev/null
+use warnings;
+use strict;
+use Test::Simple tests => 2;
+
+use overload '""' => sub { 'stringvalue' }, fallback => 1;
+
+BEGIN {
+my $x = bless {}, 'main';
+ok ($x eq 'stringvalue', 'fallback worked');
+}
+
+
+# NOTE: delete the next line and this test script will pass
+use overload '+' => sub { die "unused"; };
+
+my $x = bless {}, 'main';
+ok (eval {$x eq 'stringvalue'}, 'fallback worked again');
+