From: Sven Schöling Date: Tue, 17 Oct 2017 12:38:45 +0000 (+0200) Subject: Test für "$foo::$bar" Parsingunterschiede X-Git-Tag: release-3.5.4~678 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=bb1b5f3a563814005aa08f9d278e5aa81471b502;p=kivitendo-erp.git Test für "$foo::$bar" Parsingunterschiede Seieh https://rt.perl.org/Public/Bug/Display.html?id=128478 --- 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;