Skip to content

Commit

Permalink
Do not truncate a v-string which has underscore
Browse files Browse the repository at this point in the history
Fix #6
  • Loading branch information
moznion committed Feb 18, 2015
1 parent 70e95b2 commit fe42bd0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Perl/PrereqScanner/Lite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ sub _scan {
last if --$left_paren_num <= 0;
}
}
next;
}

# XXX Workaround for v-strings which has underscore at tail (e.g. v1.1_1).
# It is a matter of Compiler::Lexer.
#
# ref: https://github.com/moznion/Perl-PrereqScanner-Lite/issues/6
if ($is_prev_version && $token_type == KEY) {
$module_version .= $token->{data};
next;
}

if ($token_type != WHITESPACE) {
Expand Down
22 changes: 22 additions & 0 deletions t/30_v_string.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
use strict;
use warnings;
use utf8;
use FindBin;
use File::Spec::Functions qw/catfile/;
use Perl::PrereqScanner::Lite;

use t::Util;
use Test::More;
use Test::Deep;

my $scanner = Perl::PrereqScanner::Lite->new;

subtest 'basic' => sub {
my $got = $scanner->scan_file(catfile($FindBin::Bin, 'resources', 'v_string.pl'));
cmp_deeply(get_reqs_hash($got), {
'File::Temp' => 'v0.1_2',
});
};

done_testing;

2 changes: 2 additions & 0 deletions t/resources/v_string.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
use File::Temp v0.1_2;
use File::Temp v0.1_1;

0 comments on commit fe42bd0

Please sign in to comment.