| 1 | #!perl |
| 2 | |
| 3 | use 5.010001scip-perl cpan Perl-Critic 1.156 `5.010001`/; |
| 4 | use strictscip-perl cpan Perl-Critic 1.156 strict/; |
| 5 | use warningsscip-perl cpan Perl-Critic 1.156 warnings/; |
| 6 | |
| 7 | # common P::C testing tools |
| 8 | use Perl::Critic::TestUtilsscip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/ qw(pcritique fcritique); |
| 9 | |
| 10 | use Test::Morescip-perl cpan Perl-Critic 1.156 Test/More/ tests => 10; |
| 11 | |
| 12 | our $VERSIONscip-perl cpan Perl-Critic 1.156 main/$VERSION. = '1.156'; |
| 13 | |
| 14 | Perl::Critic::TestUtils::assert_versionscip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/assert_version().( $VERSIONscip-perl cpan Perl-Critic 1.156 main/$VERSION. ); |
| 15 | Perl::Critic::TestUtils::block_perlcriticrcscip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/block_perlcriticrc().(); |
| 16 | |
| 17 | # This specific policy is being tested without run.t because the .run file |
| 18 | # would have to contain invisible characters. |
| 19 | |
| 20 | my $code; |
| 21 | my $policy = 'CodeLayout::ProhibitHardTabs'; |
| 22 | my %config; |
| 23 | |
| 24 | #----------------------------------------------------------------------------- |
| 25 | |
| 26 | $code = <<"END_PERL"; |
| 27 | #This will be interpolated! |
| 28 | |
| 29 | sub my_sub { |
| 30 | \tfor(1){ |
| 31 | \t\tdo_something(); |
| 32 | \t} |
| 33 | } |
| 34 | |
| 35 | \t\t\t; |
| 36 | |
| 37 | END_PERL |
| 38 | |
| 39 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code), 0, $policy ); |
| 40 | |
| 41 | #----------------------------------------------------------------------------- |
| 42 | |
| 43 | $code = <<"END_PERL"; |
| 44 | #This will be interpolated! |
| 45 | print "\t \t foobar \t"; |
| 46 | END_PERL |
| 47 | |
| 48 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code), 1, $policy ); |
| 49 | |
| 50 | #----------------------------------------------------------------------------- |
| 51 | |
| 52 | $code = <<"END_PERL"; |
| 53 | #This will be interpolated! |
| 54 | |
| 55 | my \@list = qw( |
| 56 | \tfoo |
| 57 | \tbar |
| 58 | \tbaz |
| 59 | ); |
| 60 | |
| 61 | END_PERL |
| 62 | |
| 63 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config), 0, 'Leading tabs in qw()' ); |
| 64 | |
| 65 | #----------------------------------------------------------------------------- |
| 66 | |
| 67 | $code = <<"END_PERL"; |
| 68 | #This will be interpolated! |
| 69 | |
| 70 | my \@list = qw( |
| 71 | \tfoo\tbar |
| 72 | \tbaz\tnuts |
| 73 | ); |
| 74 | |
| 75 | END_PERL |
| 76 | |
| 77 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config), 1, 'Non-leading tabs in qw()' ); |
| 78 | |
| 79 | #----------------------------------------------------------------------------- |
| 80 | # RT #32440 |
| 81 | |
| 82 | $code = <<"END_PERL"; |
| 83 | #This will be interpolated! |
| 84 | \$x =~ m/ |
| 85 | \tsome |
| 86 | \t(really | long) |
| 87 | \tpattern |
| 88 | /mx; |
| 89 | |
| 90 | #This will be interpolated! |
| 91 | \$z = qr/ |
| 92 | \tsome |
| 93 | \t(really | long) |
| 94 | \tpattern |
| 95 | /mx; |
| 96 | |
| 97 | END_PERL |
| 98 | |
| 99 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config), 0, 'Leading tabs in extended regex' ); |
| 100 | |
| 101 | #----------------------------------------------------------------------------- |
| 102 | # RT #32440 |
| 103 | |
| 104 | $code = <<"END_PERL"; |
| 105 | #This will be interpolated! |
| 106 | #Note that these regex does not have /x, so tabs are significant |
| 107 | |
| 108 | \$x =~ m/ |
| 109 | \tsome |
| 110 | \tugly |
| 111 | \tpattern |
| 112 | /m; |
| 113 | |
| 114 | |
| 115 | \$z = qr/ |
| 116 | \tsome |
| 117 | \tugly |
| 118 | \tpattern |
| 119 | /gis; |
| 120 | |
| 121 | END_PERL |
| 122 | |
| 123 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config), 2, 'Leading tabs in non-extended regex' ); |
| 124 | |
| 125 | #----------------------------------------------------------------------------- |
| 126 | # RT #32440 |
| 127 | |
| 128 | $code = <<"END_PERL"; |
| 129 | #This will be interpolated! |
| 130 | #Note that these regex does not have /x, so tabs are significant |
| 131 | |
| 132 | \$x =~ m/ |
| 133 | \tsome\tugly\tpattern |
| 134 | /xm; |
| 135 | |
| 136 | END_PERL |
| 137 | |
| 138 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config), 1, 'Non-leading tabs in extended regex' ); |
| 139 | |
| 140 | #----------------------------------------------------------------------------- |
| 141 | |
| 142 | $code = <<"END_PERL"; |
| 143 | ##This will be interpolated! |
| 144 | |
| 145 | sub my_sub { |
| 146 | \tfor(1){ |
| 147 | \t\tdo_something(); |
| 148 | \t} |
| 149 | } |
| 150 | |
| 151 | END_PERL |
| 152 | |
| 153 | %config = (allow_leading_tabs => 0); |
| 154 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config), 3, $policy ); |
| 155 | |
| 156 | #----------------------------------------------------------------------------- |
| 157 | |
| 158 | $code = <<"END_PERL"; |
| 159 | ##This will be interpolated! |
| 160 | |
| 161 | sub my_sub { |
| 162 | ;\tfor(1){ |
| 163 | \t\tdo_something(); |
| 164 | ;\t} |
| 165 | } |
| 166 | |
| 167 | END_PERL |
| 168 | |
| 169 | %config = (allow_leading_tabs => 0); |
| 170 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config), 3, $policy ); |
| 171 | |
| 172 | #----------------------------------------------------------------------------- |
| 173 | |
| 174 | $code = <<"END_PERL"; |
| 175 | #This will be interpolated! |
| 176 | |
| 177 | __DATA__ |
| 178 | foo\tbar\tbaz |
| 179 | \tfred\barney |
| 180 | |
| 181 | END_PERL |
| 182 | |
| 183 | %config = (allow_leading_tabs => 0); |
| 184 | isscip-perl cpan Perl-Critic 1.156 main/is().( pcritiquescip-perl cpan Perl-Critic 1.156 Perl/Critic/TestUtils/pcritique().($policy, \$code, \%config), 0, 'Tabs in __DATA__' ); |
| 185 | |
| 186 | #----------------------------------------------------------------------------- |
| 187 | |
| 188 | # Local Variables: |
| 189 | # mode: cperl |
| 190 | # cperl-indent-level: 4 |
| 191 | # fill-column: 78 |
| 192 | # indent-tabs-mode: nil |
| 193 | # c-indentation-style: bsd |
| 194 | # End: |
| 195 | # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : |