Perl-Critic

 view release on metacpan or  search on metacpan

t/NamingConventions/Capitalization.run.PL  view on Meta::CPAN

    my ($test_file, $label_name, $capitalization_scheme, $failures) = @_;

    print {$test_file} <<"END_LABEL_TEST";

#-----------------------------------------------------------------------------

## name Label named "$label_name" vs the "$capitalization_scheme" capitalization scheme.
## failures $failures
## parms { labels => '$capitalization_scheme' }
## cut

$label_name:
while ( foo() ) {
    next $label_name;
}

#-----------------------------------------------------------------------------

## name Exempted label named "bLaHlAhLaH" vs the "$capitalization_scheme" capitalization scheme.
## failures 0
## parms { labels => '$capitalization_scheme', label_exemptions => 'bLa.*LaH' }
## cut

bLaHlAhLaH:
while ( foo() ) {
    next bLaHlAhLaH;
}
END_LABEL_TEST

    return;
}


sub emit_footer {
    my ($test_file) = @_;

    print {$test_file} <<'END_FOOTER';

#-----------------------------------------------------------------------------

## name Variable in continue block gets handled as a local lexical and not a scoped lexical.
## failures 1
## parms { local_lexical_variables => ':all_upper', scoped_lexical_variables => ':all_lower' }
## cut

while (blah) {
    blah;
}
continue {
    my $this_should_be_local_and_not_scoped;
}

#-----------------------------------------------------------------------------

## name Builtin variables and variables in other packages are exempt.
## failures 0
## parms { global_variables => ':all_lower' }
## cut

local $EVAL_ERROR
local @ARGV;
local %INC;
local $Foo::Bar;

#-----------------------------------------------------------------------------

## name Test customization example in the Capitalization POD passing.
## failures 0
## parms { global_variables => 'G_(?:(?!_)\w)+', global_variable_exemptions => '.*THINGY.*' }
## cut

our $G_FooBar;
our $THINGY;
our @otherTHINGY;

#-----------------------------------------------------------------------------

## name Test customization example in the Capitalization POD failing.
## failures 4
## parms { global_variables => 'G_(?:(?!_)\w)+', global_variable_exemptions => '.*THINGY.*' }
## cut

our $FooBar;
our $G_;
our $G_foo_bar;
our @THING;

#-----------------------------------------------------------------------------
# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 78
#   indent-tabs-mode: nil
#   c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :
END_FOOTER

    return;
}

#-----------------------------------------------------------------------------
# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 78
#   indent-tabs-mode: nil
#   c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :



( run in 2.052 seconds using v1.01-cache-2.11-cpan-13bb782fe5a )