From: Nicholas Clark Date: Fri, 16 Nov 2007 16:40:11 +0000 (+0000) Subject: UNITCHECK is only a keyword post 5.009, so to allow safe upgrades of X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=83b99c4fd2dfdd317bd4c2dfb4f95bf1b4deeddf;p=p5sagit%2Fp5-mst-13.2.git UNITCHECK is only a keyword post 5.009, so to allow safe upgrades of constant.pm on 5.8.x and earlier don't treat it as something special. p4raw-id: //depot/perl@32338 --- diff --git a/lib/constant.pm b/lib/constant.pm index 60d4957..cc3ee98 100644 --- a/lib/constant.pm +++ b/lib/constant.pm @@ -4,12 +4,13 @@ use strict; use warnings::register; use vars qw($VERSION %declared); -$VERSION = '1.12'; +$VERSION = '1.13'; #======================================================================= # Some names are evil choices. -my %keywords = map +($_, 1), qw{ BEGIN INIT CHECK UNITCHECK END DESTROY AUTOLOAD }; +my %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD }; +$keywords{UNITCHECK}++ if $] > 5.009; my %forced_into_main = map +($_, 1), qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG }; diff --git a/lib/constant.t b/lib/constant.t index f5bb2e6..01b7c00 100644 --- a/lib/constant.t +++ b/lib/constant.t @@ -186,7 +186,6 @@ eval q{ use constant 'BEGIN' => 1 ; use constant 'INIT' => 1 ; use constant 'CHECK' => 1 ; - use constant 'UNITCHECK' => 1; use constant 'END' => 1 ; use constant 'DESTROY' => 1 ; use constant 'AUTOLOAD' => 1 ; @@ -198,6 +197,7 @@ eval q{ use constant 'ENV' => 1 ; use constant 'INC' => 1 ; use constant 'SIG' => 1 ; + use constant 'UNITCHECK' => 1; }; my @Expected_Warnings = @@ -206,7 +206,6 @@ my @Expected_Warnings = qr/^Constant subroutine BEGIN redefined at/, qr/^Constant name 'INIT' is a Perl keyword at/, qr/^Constant name 'CHECK' is a Perl keyword at/, - qr/^Constant name 'UNITCHECK' is a Perl keyword at/, qr/^Constant name 'END' is a Perl keyword at/, qr/^Constant name 'DESTROY' is a Perl keyword at/, qr/^Constant name 'AUTOLOAD' is a Perl keyword at/, @@ -218,8 +217,17 @@ my @Expected_Warnings = qr/^Constant name 'ENV' is forced into package main:: at/, qr/^Constant name 'INC' is forced into package main:: at/, qr/^Constant name 'SIG' is forced into package main:: at/, + qr/^Constant name 'UNITCHECK' is a Perl keyword at/, ); +unless ($] > 5.009) { + # Remove the UNITCHECK warning + pop @Expected_Warnings; + # But keep the count the same + push @Expected_Warnings, qr/^$/; + push @warnings, ""; +} + # when run under "make test" if (@warnings == 16) { push @warnings, "";