From: Elizabeth Mattijsen Date: Fri, 6 Sep 2002 19:31:02 +0000 (+0000) Subject: [perl #17061] no strict 'garbage' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=210bfd0c35c99ac9c680d43346a302335cf8c627;p=p5sagit%2Fp5-mst-13.2.git [perl #17061] no strict 'garbage' From: Elizabeth Mattijsen (via RT) Date: 6 Sep 2002 19:31:02 -0000 Message-Id: Date: Sat, 07 Sep 2002 13:40:22 +0200 Message-Id: <4.2.0.58.20020907133846.02476d40@mickey.dijkmat.nl> p4raw-id: //depot/perl@17869 --- diff --git a/lib/strict.pm b/lib/strict.pm index 737cb18..c89edbf 100644 --- a/lib/strict.pm +++ b/lib/strict.pm @@ -100,7 +100,19 @@ vars => 0x00000400 sub bits { my $bits = 0; - foreach my $s (@_){ $bits |= $bitmask{$s} || 0; }; + my @wrong; + foreach my $s (@_) { + push @wrong, $s unless exists $bitmask{$s}; + $bits |= $bitmask{$s} || 0; + } + if (@wrong) { + my $useno = { + __PACKAGE__.'::import' => 'use', + __PACKAGE__.'::unimport' => 'no' + }->{ (caller(1))[3] }; + require Carp; + Carp::croak("Don't know how to '$useno ".__PACKAGE__." qw(@wrong)'"); + } $bits; } diff --git a/lib/strict.t b/lib/strict.t index 80076fc..a95b563 100644 --- a/lib/strict.t +++ b/lib/strict.t @@ -36,7 +36,7 @@ foreach (sort glob($^O eq 'MacOS' ? ":lib:strict:*" : "lib/strict/*")) { undef $/; -print "1..", scalar @prgs, "\n"; +print "1..", @prgs + 4, "\n"; for (@prgs){ @@ -98,3 +98,19 @@ for (@prgs){ foreach (@temps) { unlink $_ if $_ } } + +eval qq(use strict 'garbage'); +print +($@ =~ /^Don't know how to 'use strict qw\(garbage\)/) + ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@"; + +eval qq(no strict 'garbage'); +print +($@ =~ /^Don't know how to 'no strict qw\(garbage\)/) + ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@"; + +eval qq(use strict qw(foo bar)); +print +($@ =~ /^Don't know how to 'use strict qw\(foo bar\)/) + ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@"; + +eval qq(no strict qw(foo bar)); +print +($@ =~ /^Don't know how to 'no strict qw\(foo bar\)/) + ? "ok ".++$i."\n" : "not ok ".++$i."\t# $@";