Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/PPI/Token/DashedWord.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ sub __TOKENIZER__on_char {

# Suck to the end of the dashed bareword
pos $t->{line} = $t->{line_cursor};
if ( $t->{line} =~ m/\G(\w+)/gc ) {
if ( $t->{line} =~ m/\G(\w+(?:(?:\'|::)\w+)*(?:::)?)/gc ) {
$t->{token}->{content} .= $1;
$t->{line_cursor} += length $1;
}
Expand Down
26 changes: 25 additions & 1 deletion t/08_regression.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use if !(-e 'META.yml'), "Test::InDistDir";
use lib 't/lib';
use PPI::Test::pragmas;
use Test::More tests => 1121 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
use Test::More tests => 1133 + ($ENV{AUTHOR_TESTING} ? 1 : 0);

use PPI ();
use PPI::Test qw( pause );
Expand Down Expand Up @@ -368,3 +368,27 @@ END_PERL
my $match = $doc->find('PPI::Token::Regexp::Match');
is( scalar(@$match), 3, 'Found expected number of matches' );
}



#####################################################################
# Regression Test for GitHub #59 / RT #30037
# Minus operator should not split namespaced function names

SCOPE: {
my $doc = safe_new \'$a=-xx::cc()';
my @words = grep { $_->isa('PPI::Token::Word') } $doc->tokens;
is( scalar @words, 1, '-xx::cc() has a single Word token' );
is( $words[0] && $words[0]->content, '-xx::cc', '-xx::cc content is correct' );

my $doc2 = safe_new \'-foo::bar';
my @words2 = grep { $_->isa('PPI::Token::Word') } $doc2->tokens;
is( scalar @words2, 1, '-foo::bar is a single Word token' );
is( $words2[0] && $words2[0]->content, '-foo::bar', '-foo::bar content is correct' );

my $doc3 = safe_new \"-foo'bar";
my $word3 = $doc3->find_first('Token::Word');
is( $word3 && $word3->content, "-foo'bar", "-foo'bar is a single Word token" );
my $quote = $doc3->find_first('Token::Quote::Single');
is( $quote, '', "-foo'bar produces no Quote::Single tokens" );
}
Loading