constant

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

1.15    2007.12.31    SAPER (Sébastien Aperghis-Tramoni)
        [TEST] Adjusted t/constant.t to how empty prototypes are reported
        among different versions of Perl (thus fixing the FAIL reports for 
        Perl 5.8.0 to 5.8.3).

1.14    2007.12.27    SAPER (Sébastien Aperghis-Tramoni)
        [DIST] CPAN-RT#31627: Specify core install dir in Build.PL. 
        Thanks to Michael G Schwern.

1.13    2007.12.27    SAPER (Sébastien Aperghis-Tramoni)
        [CODE] Merged changed blead@32338: UNITCHECK is only a keyword 
        post 5.009 (Nicholas Clark).
        [DIST] Copied the sysnopsis into eg/

1.12    2007.11.06    SAPER (Sébastien Aperghis-Tramoni)
        [DIST] CPAN-RT#30460: The module must be installed in core, not in
        site (because it get shadowed). Thanks to Imacat.

1.11    2007.09.25    SAPER (Sébastien Aperghis-Tramoni)
        [CODE] Fixed code and tests so everything work under Perl 5.005.
        [DOC] Some Pod nits. Added information about current maintainers.

1.10    2007.04.19
        blead@30980: C3 MRO support (Brandon L Black).
        blead@30824: Small fix for Symbian (Jarkko Hietaniemi).

1.09    2007.03.13
        blead@30561: Inform constant.pm about UNITCHECK (Joshua ben Jore).

1.08    2007.02.13
        blead@30255: Remove some debugging code (Nicholas Clark).
        blead@26502: Use Internals::inc_sub_generation() to invalidate 
          cached methods (Nicholas Clark).

1.07    2005.12.26
        blead@26487: Rework constant.pm to take advantage of the space 
          savings of proxy constant subroutines whenever it can (Nicholas Clark).
        blead@26485: Factore caller() call out of the loop (Nicholas Clark).

lib/constant.pm  view on Meta::CPAN

use strict;
use warnings::register;

our $VERSION = '1.33';
our %declared;

#=======================================================================

# Some names are evil choices.
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 };

my %forbidden = (%keywords, %forced_into_main);

my $normal_constant_name = qr/^_?[^\W_0-9]\w*\z/;
my $tolerable = qr/^[A-Za-z_]\w*\z/;
my $boolean = qr/^[01]?\z/;

t/constant.t  view on Meta::CPAN

    use constant 'DESTROY' => 1 ;
    use constant 'AUTOLOAD' => 1 ;
    use constant 'STDIN' => 1 ;
    use constant 'STDOUT' => 1 ;
    use constant 'STDERR' => 1 ;
    use constant 'ARGV' => 1 ;
    use constant 'ARGVOUT' => 1 ;
    use constant 'ENV' => 1 ;
    use constant 'INC' => 1 ;
    use constant 'SIG' => 1 ;
    use constant 'UNITCHECK' => 1;
};

my @Expected_Warnings = 
  (
   qr/^Constant name 'BEGIN' is a Perl keyword at/,
   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 'END' is a Perl keyword at/,
   qr/^Constant name 'DESTROY' is a Perl keyword at/,
   qr/^Constant name 'AUTOLOAD' is a Perl keyword at/,
   qr/^Constant name 'STDIN' is forced into package main:: a/,
   qr/^Constant name 'STDOUT' is forced into package main:: at/,
   qr/^Constant name 'STDERR' is forced into package main:: at/,
   qr/^Constant name 'ARGV' is forced into package main:: at/,
   qr/^Constant name 'ARGVOUT' is forced into package main:: at/,
   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, "";
    push @Expected_Warnings, qr/^$/;



( run in 1.201 second using v1.01-cache-2.11-cpan-748bfb374f4 )