make sure we don't get warnings about redefining symbols
Jesse Luehrs [Wed, 30 Nov 2011 00:08:15 +0000 (18:08 -0600)]
lib/Package/Stash/PP.pm
t/edge-cases.t

index 8d95840..a831564 100644 (file)
@@ -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;
         }
index d1e5182..262c13b 100755 (executable)
@@ -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;