Skip to content

Commit

Permalink
parse things like v49use as a single bareword, not v-string + keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
moregan authored and wchristian committed May 14, 2017
1 parent 6768375 commit cfc8125
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Revision history for Perl extension PPI
(MOREGAN)
- parse package names that look like v10 as strings, not versions
(MOREGAN)
- parse things like v49use as a single bareword, not v-string + keyword
(MOREGAN)

1.220 Tue 11 Nov 2014
Summary:
Expand Down
2 changes: 1 addition & 1 deletion lib/PPI/Token/Number/Version.pm
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ sub __TOKENIZER__commit {

# Capture the rest of the token
pos $t->{line} = $t->{line_cursor};
if ( $t->{line} !~ m/\G(v\d+(?:\.\d+)*)/gc ) {
if ( $t->{line} !~ m/\G(v\d+(?:\.\d+)+|v\d+\b)/gc ) {
# This was not a v-string after all (it's a word)
return PPI::Token::Word->__TOKENIZER__commit($t);
}
Expand Down
6 changes: 1 addition & 5 deletions t/ppi_token_number_version.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ LITERAL: {


VSTRING_ENDS_CORRECTLY: {
my %known_bad = map { $_ => 1 } map { "v49$_" } qw'abs accept alarm and atan2 bind binmode bless break caller chdir chmod chomp chop chown chr chroot close closedir cmp connect continue cos crypt dbmclose dbmopen default defined delete die do dump e10 each else elsif endgrent endhostent endnetent endprotoent endpwent endservent eof eq eval evalbytes exec exists exit exp fc fcntl fileno flock for foreach fork format formline ge getc getgrent getgrgid getgrnam gethostbyaddr gethostbyname gethostent getlogin getnetbyaddr getnetbyname getnetent getpeername getpgrp getppid getpriority getprotobyname getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyname getservbyport getservent getsockname getsockopt given glob gmtime goto grep gt hex if index int ioctl join keys kill last lc lcfirst le length link listen local localtime lock log lstat lt m map mkdir msgctl msgget msgrcv msgsnd my ne next no not oct open opendir or ord our pack package pipe pop pos print printf prototype push q qq qr quotemeta qw qx rand read readdir readline readlink readpipe recv redo ref rename require reset return reverse rewinddir rindex rmdir s say scalar seek seekdir select semctl semget semop send setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockopt shift shmctl shmget shmread shmwrite shutdown sin sleep socket socketpair sort splice split sprintf sqrt srand stat state study sub substr symlink syscall sysopen sysread sysseek system syswrite tell telldir tie tied time times tr truncate uc ucfirst umask undef unless unlink unpack unshift untie until use utime values vec wait waitpid wantarray warn when while write x x3 xor y';
my @tests = (
(
map {
Expand Down Expand Up @@ -87,15 +86,12 @@ VSTRING_ENDS_CORRECTLY: {
$tokens = [ map { ref($_), $_->content() } @$tokens ];
my $expected = $test->{expected};
unshift @$expected, 'PPI::Statement', $test->{code};
TODO: {
local $TODO = $known_bad{$test->{code}} ? "known bug" : undef;
my $ok = is_deeply( $tokens, $expected, $test->{desc} );
if ( !$known_bad{$test->{code}} and !$ok ) {
if ( !$ok ) {
diag "$test->{code} ($test->{desc})\n";
diag explain $tokens;
diag explain $test->{expected};
}
}
}
}

Expand Down

0 comments on commit cfc8125

Please sign in to comment.