Perl-Lint

 view release on metacpan or  search on metacpan

t/Policy/ControlStructures/prohibit_labels_with_special_block_names.t  view on Meta::CPAN

use strict;
use warnings;
use Perl::Lint::Policy::ControlStructures::ProhibitLabelsWithSpecialBlockNames;
use t::Policy::Util qw/fetch_violations/;
use Test::Base::Less;

my $class_name = 'ControlStructures::ProhibitLabelsWithSpecialBlockNames';

filters {
    params => [qw/eval/],
};

for my $block (blocks) {
    my $violations = fetch_violations($class_name, $block->input, $block->params);
    is scalar @$violations, $block->failures, $block->dscr;
}

done_testing;

__DATA__

===
--- dscr: Basic passing
--- failures: 0
--- params:
--- input
BEGIN       { $x = 1; }
END         { $x = 1; }
CHECK       { $x = 1; }
INIT        { $x = 1; }
UNITCHECK   { $x = 1; }

===
--- dscr: Failure, cuddled colon
--- failures: 5
--- params:
--- input
BEGIN:      { $x = 1; }
END:        { $x = 1; }
CHECK:      { $x = 1; }
INIT:       { $x = 1; }
UNITCHECK:  { $x = 1; }

===
--- dscr: Failure, uncuddled colon
--- failures: 5
--- params:
--- input
BEGIN :     { $x = 1; }
END :       { $x = 1; }
CHECK :     { $x = 1; }
INIT :      { $x = 1; }
UNITCHECK : { $x = 1; }

===
--- dscr: no lint
--- failures: 4
--- params:
--- input
BEGIN:      { $x = 1; }
END:        { $x = 1; }
CHECK:      { $x = 1; } ## no lint
INIT:       { $x = 1; }
UNITCHECK:  { $x = 1; }



( run in 0.896 second using v1.01-cache-2.11-cpan-364913b4093 )