Skip to content

Commit

Permalink
Build results of 71219d7 (on master)
Browse files Browse the repository at this point in the history
  • Loading branch information
kentfredric committed Apr 9, 2016
1 parent 3955048 commit 940deb5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Release history for Perl-PrereqScanner-Scanner-Runtime

0.001000 2016-04-09T18:01:04Z b57c196
0.001000 2016-04-09T18:05:02Z 71219d7
- First version.

1 change: 1 addition & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ t/00-report-prereqs.dd
t/00-report-prereqs.t
t/all_scanners.t
t/class-load/basic.t
t/class-load/ignore.t
t/module-load/basic.t
t/module-load/ignored.t
t/module-runtime/fully_qualified.t
Expand Down
12 changes: 8 additions & 4 deletions lib/Perl/PrereqScanner/Scanner/Class/Load.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ my %functions = (
try_load_class => '_get_pn',
load_optional_class => '_get_pn',
);
my %subs = (
map { ( "Class::Load::$_" => [ $functions{$_}, $_ ], "$_" => [ $functions{$_}, $_ ], ) } keys %functions
);
my %subs = ( map { ( "Class::Load::$_" => [ $functions{$_}, $_ ], "$_" => [ $functions{$_}, $_ ], ) } keys %functions );



Expand All @@ -47,13 +45,19 @@ sub scan_for_prereqs {
sub {
return q[] unless $_[1]->isa('PPI::Statement');
my (@children) = $_[1]->schildren;
while ( my $child = shift @children ) {
my ( $child, $previous );
while (@children) {
$previous = $child;
$child = shift @children;

# Match sub call
next
unless $child->isa('PPI::Token::Word')
and $child->literal =~ qr/$literal_re/sx;

# Skip methods
next if $previous and $previous->isa('PPI::Token::Operator') and q{->} eq $previous->content;

# Handle a list of arguments as token->next
if ( $children[0]->isa('PPI::Structure::List') ) {
push @interesting, [ $child->literal, shift @children ];
Expand Down
32 changes: 32 additions & 0 deletions t/class-load/ignore.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use strict;
use warnings;

use Test::More;

# ABSTRACT: Basic class load tests

use Perl::PrereqScanner;
my $scanner = Perl::PrereqScanner->new( extra_scanners => [qw( Class::Load )], );
my $prereqs = $scanner->scan_string(
q[
use Class::Load;
$thing->load_class("My::ClassA");
$thing->try_load_class(q{My::ClassB});
$thing->load_optional_class('My::ClassC');
]
)->as_string_hash;

my $diag_needed;

$diag_needed = 1 unless ok( !exists $prereqs->{"My::ClassA"}, "ClassA reported" );
$diag_needed = 1 unless ok( !exists $prereqs->{"My::ClassB"}, "ClassB reported" );
$diag_needed = 1 unless ok( !exists $prereqs->{"My::ClassC"}, "ClassC reported" );

if ($diag_needed) {
diag explain $prereqs;
}

done_testing;

1 change: 1 addition & 0 deletions xt/author/eol.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ my @files = (
't/00-report-prereqs.t',
't/all_scanners.t',
't/class-load/basic.t',
't/class-load/ignore.t',
't/module-load/basic.t',
't/module-load/ignored.t',
't/module-runtime/fully_qualified.t',
Expand Down

0 comments on commit 940deb5

Please sign in to comment.