Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Silence redefine warnings in alias() #191

Merged
merged 2 commits into from

2 participants

@doherty

This blindly turns off redefine warnings in alias() on the assumption that the user means to do that.

Fixes #185

@doherty doherty Silence redefine warnings in alias()
This blindly turns off redefine warnings in alias() on the
assumption that the user means to do that.

Fixes #185
2e5ccb2
@schwern
Owner

Thanks. Needs a test.

@schwern schwern merged commit 6a716e9 into evalEmpire:master
@schwern
Owner

Thank, merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 23, 2011
  1. @doherty

    Silence redefine warnings in alias()

    doherty authored
    This blindly turns off redefine warnings in alias() on the
    assumption that the user means to do that.
    
    Fixes #185
Commits on Apr 28, 2011
  1. @doherty
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 4 deletions.
  1. +4 −2 lib/perl5i/2/UNIVERSAL.pm
  2. +11 −2 t/alias.t
View
6 lib/perl5i/2/UNIVERSAL.pm
@@ -10,13 +10,15 @@ require Carp;
sub alias {
my $self = shift;
- Carp::croak("Not enough arguments given to alias()") unless @_;
+ Carp::croak('Not enough arguments given to alias()') unless @_;
my @name = @_;
unshift @name, (caller)[0] unless @name > 1 or grep /::/, @name;
- my $name = join "::", @name;
+ my $name = join '::', @name;
+ # If this redefines something, assume the user wanted to
+ no warnings 'redefine';
no strict 'refs';
*{$name} = $self;
return 1;
View
13 t/alias.t
@@ -3,7 +3,7 @@
use perl5i::latest;
use Test::More;
-
+use Test::Warn;
# Test name construction
{
@@ -75,4 +75,13 @@ use Test::More;
}
-done_testing();
+# No redefine warnings:
+{
+ sub egg { 42 }
+ sub ham { 10 }
+ warning_is {
+ (\&egg)->alias('ham');
+ } undef, 'no warning';
+}
+
+done_testing;
Something went wrong with that request. Please try again.