Skip to content

Commit

Permalink
also support import
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg authored and Arthur Axel 'fREW' Schmidt committed Jul 24, 2014
1 parent 76cf82f commit eddcbd9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Revision history for {{$dist->name}}

{{$NEXT}}
- Fix overeager warnings disablement (Thanks Graham Knop for fix and pjfl
for bug report)

0.001001 2012-11-17 16:31:55 CST6CDT
- Put MetaYAML back in dist
Expand Down
9 changes: 9 additions & 0 deletions lib/warnings/illegalproto.pm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ BEGIN {
*_ILLEGALPROTO_SUPPORTED = $] >= 5.012 ? sub(){1} : sub(){0};
}

sub import {
if (_ILLEGALPROTO_SUPPORTED) {
warnings->import('illegalproto')
}
else {
${^WARNING_BITS} |= $WARN
}
}

sub unimport {
if (_ILLEGALPROTO_SUPPORTED) {
warnings->unimport('illegalproto')
Expand Down
14 changes: 14 additions & 0 deletions t/import.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use strict;
use Test::More;

use warnings::illegalproto;

$SIG{__WARN__} = sub { die $_[0] };

my $x = eval "sub (frew) { 1 }";
like $@, qr/prototype/, 'dies on "bad" prototype';

eval 'my $f = undef . "foo"';
is $@, '', 'other warnings not enabled';

done_testing;

0 comments on commit eddcbd9

Please sign in to comment.