3 ##############################################################################
4 # $URL: http://perlcritic.tigris.org/svn/perlcritic/trunk/Perl-Critic/t/20_policy_requiretidycode.t $
5 # $Date: 2008-06-21 19:57:54 -0700 (Sat, 21 Jun 2008) $
8 ##############################################################################
14 use Test::More tests => 6;
16 # common P::C testing tools
17 use Perl::Critic::TestUtils qw(pcritique);
18 Perl::Critic::TestUtils::block_perlcriticrc();
21 my $policy = 'CodeLayout::RequireTidyCode';
24 #-----------------------------------------------------------------------------
32 my $has_perltidy = eval {require Perl::Tidy};
33 %config = (perltidyrc => q{});
35 eval { pcritique($policy, \$code, \%config) },
36 $has_perltidy ? 1 : undef,
40 #-----------------------------------------------------------------------------
43 #Only one trailing newline
48 %config = (perltidyrc => q{});
50 eval { pcritique($policy, \$code, \%config) },
51 $has_perltidy ? 0 : undef,
52 'Tidy with one trailing newline',
55 #-----------------------------------------------------------------------------
58 #Two trailing newlines
64 %config = (perltidyrc => q{});
66 eval { pcritique($policy, \$code, \%config) },
67 $has_perltidy ? 0 : undef,
68 'Tidy with two trailing newlines',
71 #-----------------------------------------------------------------------------
74 #Several trailing newlines
87 %config = (perltidyrc => q{});
89 eval { pcritique($policy, \$code, \%config) },
90 $has_perltidy ? 0 : undef,
91 'Tidy with several trailing newlines',
94 #-----------------------------------------------------------------------------
105 %config = (perltidyrc => q{});
107 eval { pcritique($policy, \$code, \%config) },
108 $has_perltidy ? 0 : undef,
112 #-----------------------------------------------------------------------------
114 $code = <<'END_PERL';
117 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
118 if 0; # not running under some shell
123 %config = (perltidyrc => q{});
125 eval { pcritique($policy, \$code, \%config) },
126 $has_perltidy ? 0 : undef,
127 'Tidy with shell escape',
130 #-----------------------------------------------------------------------------
132 # ensure we run true if this test is loaded by
133 # t/20_policy_requiretidycode.t_without_optional_dependencies.t
138 # cperl-indent-level: 4
140 # indent-tabs-mode: nil
141 # c-indentation-style: bsd
143 # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :