Perl-Lint

 view release on metacpan or  search on metacpan

t/Policy/NamingConventions/capitalization.PL  view on Meta::CPAN

        say \$$variable_name;
    }
}

END_LOCAL_LEXICAL_VARIABLE_TEST

    return;
}

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

    print {$test_file} <<"END_LABEL_TEST";
===
--- dscr: Label named "$label_name" vs the "$capitalization_scheme" capitalization scheme.
--- failures: $failures
--- params: {capitalization => {labels => '$capitalization_scheme'}}
--- input
$label_name:
while ( foo() ) {
    next $label_name;
}

===
--- dscr: Exempted label named "bLaHlAhLaH" vs the "$capitalization_scheme" capitalization scheme.
--- failures: 0
--- params: {capitalization => {labels => '$capitalization_scheme', label_exemptions => 'bLa.*LaH'}}
--- input
bLaHlAhLaH:
while ( foo() ) {
    next bLaHlAhLaH;
}
END_LABEL_TEST

    return;
}

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

    print {$test_file} <<'END_FOOTER';
# NOTE need it?
# ===
# --- dscr: Variable in continue block gets handled as a local lexical and not a scoped lexical.
# --- failures: 1
# --- params: {capitalization => {local_lexical_variables => ':all_upper', scoped_lexical_variables => ':all_lower'}}
# --- input
# while (blah) {
#     blah;
# }
# continue {
#     my $this_should_be_local_and_not_scoped;
# }

===
--- dscr: Builtin variables and variables in other packages are exempt.
--- failures: 0
--- params: {capitalization => {global_variables => ':all_lower'}}
--- input
local $EVAL_ERROR
local @ARGV;
local %INC;
local $Foo::Bar;

===
--- dscr: Test customization example in the Capitalization POD passing.
--- failures: 0
--- params: {capitalization => {global_variables => 'G_(?:(?!_)\w)+', global_variable_exemptions => '.*THINGY.*'}}
--- input
our $G_FooBar;
our $THINGY;
our @otherTHINGY;

===
--- dscr: Test customization example in the Capitalization POD failing.
--- failures: 4
--- params: {capitalization => {global_variables => 'G_(?:(?!_)\w)+', global_variable_exemptions => '.*THINGY.*'}}
--- input
our $FooBar;
our $G_;
our $G_foo_bar;
our @THING;

===
--- dscr: no lint
--- failures: 3
--- params: {capitalization => {global_variables => 'G_(?:(?!_)\w)+', global_variable_exemptions => '.*THINGY.*'}}
--- input
our $FooBar;
our $G_;
our $G_foo_bar; ## no lint
our @THING;

END_FOOTER

    return;
}



( run in 0.959 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )