From: Jesse Luehrs Date: Wed, 30 Nov 2011 00:08:15 +0000 (-0600) Subject: make sure we don't get warnings about redefining symbols X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f253ff9ea6aad9021b3a0d15449e8097d348402a;p=gitmo%2FPackage-Stash.git make sure we don't get warnings about redefining symbols --- diff --git a/lib/Package/Stash/PP.pm b/lib/Package/Stash/PP.pm index 8d95840..a831564 100644 --- a/lib/Package/Stash/PP.pm +++ b/lib/Package/Stash/PP.pm @@ -185,6 +185,7 @@ sub add_symbol { $namespace->{$name} ||= *{ Symbol::gensym() }; if (@_ > 2) { + no warnings 'redefine'; *{ $namespace->{$name} } = ref $initial_value ? $initial_value : \$initial_value; } diff --git a/t/edge-cases.t b/t/edge-cases.t index d1e5182..262c13b 100755 --- a/t/edge-cases.t +++ b/t/edge-cases.t @@ -80,4 +80,13 @@ SKIP: { ); } +{ + my $warning; + local $SIG{__WARN__} = sub { $warning = $_[0] }; + my $stash = Package::Stash->new('Bar'); + $stash->add_symbol('&foo' => sub { }); + $stash->add_symbol('&foo' => sub { }); + is($warning, undef, "no redefinition warnings"); +} + done_testing;