X-Git-Url: http://wagnertech.de/git?p=kivitendo-erp.git;a=blobdiff_plain;f=t%2Fstructure%2Fdouble_colon_interpolation.t;fp=t%2Fstructure%2Fdouble_colon_interpolation.t;h=2b0dce0fb37e6e80c38eb9aefcc50ab54b869252;hp=0000000000000000000000000000000000000000;hb=53593baa211863fbf66540cf1bcc36c8fb37257f;hpb=deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44 diff --git a/t/structure/double_colon_interpolation.t b/t/structure/double_colon_interpolation.t new file mode 100644 index 000000000..2b0dce0fb --- /dev/null +++ b/t/structure/double_colon_interpolation.t @@ -0,0 +1,57 @@ +use strict; +use threads; +use lib 't'; +use Support::Files; +use Sys::CPU; +use Test::More; +use Thread::Pool::Simple; + +if (eval { require PPI; 1 }) { + plan tests => scalar(@Support::Files::testitems); +} else { + plan skip_all => "PPI not installed"; +} + +my @testitems = @Support::Files::testitems; + +sub test_file { + my ($file) = @_; + + my $clean = 1; + my $source; + { + local $^W = 0; # don't care about invalid chars in comments + local $/ = undef; + open my $fh, '<:utf8', $file or die $!; + $source = <$fh>; + } + + my $doc = PPI::Document->new(\$source) or do { + print "?: PPI error for file $file: " . PPI::Document::errstr() . "\n"; + ok 0, $file; + next; + }; + my $stmts = $doc->find(sub { $_[1]->isa('PPI::Token::Quote::Double') || $_[1]->isa('PPI::Token::Quote::Interpolate') }); + + for my $stmt (@{ $stmts || [] }) { + my $content = $stmt->content; + + if ($content =~ /(\$\w+::)\$/) { + print "?: @{[ $stmt->content ]} contains $1 \n"; + $clean = 0; + } + } + + ok $clean, $file; +} + +my $pool = Thread::Pool::Simple->new( + min => 2, + max => Sys::CPU::cpu_count() + 1, + do => [ \&test_file ], + passid => 0, +); + +$pool->add($_) for @testitems; + +$pool->join;