summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-11-29 18:08:15 -0600
committerJesse Luehrs <doy@tozt.net>2011-11-29 18:08:15 -0600
commitf253ff9ea6aad9021b3a0d15449e8097d348402a (patch)
tree57945d958640771d6260c6deaf68c7d74db3257c
parentacbc69c4f1ade78eb1d6f951cb6336af4297d996 (diff)
downloadpackage-stash-f253ff9ea6aad9021b3a0d15449e8097d348402a.tar.gz
package-stash-f253ff9ea6aad9021b3a0d15449e8097d348402a.zip
make sure we don't get warnings about redefining symbols
-rw-r--r--lib/Package/Stash/PP.pm1
-rwxr-xr-xt/edge-cases.t9
2 files changed, 10 insertions, 0 deletions
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;