1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
#!perl
##############################################################################
# $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/distributions/Perl-Critic/t/20_policy_prohibit_trailing_whitespace.t $
# $Date: 2010-06-22 16:14:07 -0400 (Tue, 22 Jun 2010) $
# $Author: clonezone $
# $Revision: 3843 $
##############################################################################
use 5.006001;
use strict;
use warnings;
use Perl::Critic::Utils qw( :characters );
use Perl::Critic::TestUtils qw( pcritique );
use Test::More tests => 3;
#-----------------------------------------------------------------------------
our $VERSION = '1.108';
#-----------------------------------------------------------------------------
Perl::Critic::TestUtils::block_perlcriticrc();
# This specific policy is being tested without 20_policies.t because the .run file
# would have to contain invisible characters.
my $code;
my $policy = 'CodeLayout::ProhibitTrailingWhitespace';
#-----------------------------------------------------------------------------
$code = <<"END_PERL";
say${SPACE}"\tblurp\t";\t
say${SPACE}"${SPACE}blorp${SPACE}";${SPACE}
\f
chomp;\t${SPACE}${SPACE}
chomp;${SPACE}${SPACE}\t
END_PERL
is( pcritique($policy, \$code), 5, 'Basic failure' );
#-----------------------------------------------------------------------------
$code = <<"END_PERL";
sub${SPACE}do_frobnication${SPACE}\{
\tfor${SPACE}(${SPACE}is_frobnicating()${SPACE})${SPACE}\{
${SPACE}${SPACE}${SPACE}${SPACE}frobnicate();
\l}
}
END_PERL
is( pcritique($policy, \$code), 0, 'Basic passing' );
#-----------------------------------------------------------------------------
$code = <<"END_PERL";
${SPACE}
${SPACE}\$x
END_PERL
is(
pcritique($policy, \$code),
1,
'Multiple lines in a single PPI::Token::Whitespace',
);
#-----------------------------------------------------------------------------
# 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 :
|