Commit a7105582 authored by Florian Schlichting's avatar Florian Schlichting

Imported Upstream version 0.31

parent cacf5f42
......@@ -18,7 +18,7 @@ sub process_grammar_files {
open(my $fh,'<',$grammar) || die "cannot read $grammar: $!";
my @content = <$fh>;
close $fh;
splice(@content,1,0,'our $VERSION=0.29;'."\n");
splice(@content,1,0,'our $VERSION=0.31;'."\n");
open(my $out,">",$grammar) || die "cannot write $grammer: $!";
print $out @content;
close $out;
......@@ -55,7 +55,7 @@ my %module_build_args = (
'Thomas Klausner <domm@cpan.org>'
],
'dist_name' => 'Module-ExtractUse',
'dist_version' => '0.29',
'dist_version' => '0.31',
'license' => 'perl',
'module_name' => 'Module::ExtractUse',
'module_name' => 'Module::ExtractUse',
......
......@@ -2,6 +2,29 @@
# Changes for Module::ExtractUse
#-----------------------------------------------------------------
0.31 2013-05-31T10:21:06+0200
- applied a patch from cjm with slight modification to resolve RT#50723
(support use Foo::Bar (); etc) (Kenichi Ishigaki)
- fixed RT#71761 (Kenichi Ishigaki)
- applied a patch from wyant (RT#71761) (Kenichi Ishigaki)
- fixed the Pod::Simple encoding issue (Kenichi Ishigaki)
- Fix incorrect regexp (ref gh-5). (Yasutaka ATARASHI)
- Avoid regex features introduced only in later perl (close gh-5).
(Yasutaka ATARASHI)
- Use plan() instead of done_testing() (ref gh-5). (Yasutaka ATARASHI)
- Add support for bareword leading hyphyen, in-place arrayref and hashref.
(Yasutaka ATARASHI)
- proper version number for older releases (Brian Cassidy)
0.30 2013-04-18T08:57:49+0200
- Add accessors and tests for _in_eval/_out_of_eval. (Yasutaka ATARASHI)
- reworked 80_failig.t to TODO tests; (Thomas Klausner)
- added more require-in-string corner test cases (suggested by Buddy Burden)
(Thomas Klausner)
- Fix the case for eval["']expr["'] and add regression tests.
(Yasutaka ATARASHI)
0.29 2013-02-25T20:25:44+0100
- fixed regex to filter use/require (RT83569) (reported by
ribasushi)
......@@ -119,12 +142,12 @@
- Enhanced grammer (thanks to $::RD_TRACE)
0.5 2003-04-18
0.05 2003-04-18
- added precompilation of grammar to Makefile.PL
- changed @found to @::found
- init @::found in start-rule instead via startup-action
0.3 2003-03-31
0.03 2003-03-31
- sort of working
......@@ -19,6 +19,7 @@ t/22_eval.t
t/23_universal_require.t
t/24_version.t
t/25_utf8.t
t/26_pod_encoding.t
t/80_failing.t
xt/pod.t
xt/pod_coverage.t
......@@ -52,6 +52,6 @@
"web" : "http://github.com/domm/Module-ExtractUse"
}
},
"version" : "0.29"
"version" : "0.31"
}
......@@ -27,4 +27,4 @@ requires:
warnings: 0
resources:
repository: git://github.com/domm/Module-ExtractUse.git
version: 0.29
version: 0.31
This archive contains the distribution Module-ExtractUse,
version 0.29:
version 0.31:
Find out what modules are used
......
......@@ -2,7 +2,7 @@
# Rules for use
#-----------------------------------------------------------------
token_use: /\buse\s/ use_stuff ';'
token_use: /\buse\s/ use_stuff /[;}]/
{ $return=$item{use_stuff} }
use_stuff: (base | pragma | version | module)
......@@ -23,7 +23,7 @@ module_more: eos | version(?) var(?) import_list(?)
# Rules for require
#-----------------------------------------------------------------
token_require: /\brequire\s/ require_stuff ';'
token_require: /\brequire\s/ require_stuff /[;}]/
{ $return=$item{require_stuff} }
require_stuff: (version | require_name | module)
......@@ -53,10 +53,14 @@ import_list: /[(]?/
{ $return=$item[2];
$return.=" ".join(" ",@{$item[3]}) if $item[3];
}
|
/[(]\s*[)]/ { $return='' }
list_item: <perl_quotelike> { $return=$item[1][2] }
|
/\w+/ { $return=$item[1] }
<perl_codeblock (){}[]> { $return=$item[1] }
|
/-?\w+/ { $return=$item[1] }
comma_list_item: comma list_item
{ $return=$item{list_item} }
......
......@@ -8,7 +8,7 @@ use Pod::Strip;
use Parse::RecDescent 1.967009;
use Module::ExtractUse::Grammar;
use Carp;
use version; our $VERSION=version->new('0.29');
use version; our $VERSION=version->new('0.31');
# ABSTRACT: Find out what modules are used
......@@ -26,6 +26,55 @@ sub new {
}
# Regular expression to detect eval
# On newer perl, you can use named capture groups and (?&name) for recursive regex
# However, it requires perl newer than 5.008 declared as requirement in this module
my $re_block;
$re_block = qr {
( # eval BLOCK, corresponding to the group 10 in the entire regex
{
((?:
(?> [^{}]+ ) # Non-braces without backtracking
|
(??{$re_block}) # Recurse to group 10
)*)
}
)
}xs;
my $re = qr{
\G(.*?) # group 1
eval
(?:
(?:\s+
(?:
qq?\((.*?)\) # eval q(), group 2
|
qq?\[(.*?)\] # eval q[], group 3
|
qq?{(.*?)} # eval q{}, group 4
|
qq?<(.*?)> # eval q<>, group 5
|
qq?(\S)(.*?)\6 # eval q'' or so, group 6, group 7
)
)
|
(?:\s*(?:
(?:(['"])(.*?)\8) # eval '' or eval "", group 8, group 9
|
( # eval BLOCK, group 10
{
((?: # group 11
(?> [^{}]+ ) # Non-braces without backtracking
|
(??{$re_block}) # Recurse to group 10
)*)
}
)
))
)
}xs;
sub extract_use {
my $self=shift;
my $code_to_parse=shift;
......@@ -33,6 +82,7 @@ sub extract_use {
my $podless;
my $pod_parser=Pod::Strip->new;
$pod_parser->output_string(\$podless);
$pod_parser->parse_characters(1) if $pod_parser->can('parse_characters');
if (ref($code_to_parse) eq 'SCALAR') {
$pod_parser->parse_string_document($$code_to_parse);
}
......@@ -41,28 +91,24 @@ sub extract_use {
}
# Strip obvious comments.
$podless =~ s/^\s*#.*$//mg;
$podless =~ s/(^|[\};])\s*#.*$/$1/mg;
my @statements;
while($podless =~ /$re/gc) {
# to keep parsing time short, split code in statements
# (I know that this is not very exact, patches welcome!)
my @statements=split(/;/,$podless);
my $pre = $1;
my $eval = join('', grep { defined $_ } ($2, $3, $4, $5, $7, $9, $11));
push @statements, map { [ 0, $_ ] } split(/;/, $pre); # non-eval context
push @statements, map { [ 1, $_ ] } split(/;/, $eval); # eval context
}
push @statements, map { [ 0, $_ ] } split(/;/, substr($podless, pos($podless) || 0)); # non-eval context
foreach my $statement (@statements) {
foreach my $statement_ (@statements) {
my ($eval, $statement) = @$statement_;
$statement=~s/\n+/ /gs;
my $result;
# check for string eval in ' ', " " strings
if ($statement !~ s/eval\s+(['"])(.*?)\1/$2;/) {
# if that didn't work, try q and qq strings
if ($statement !~ s/eval\s+qq?(\S)(.*?)\1/$2;/) {
# finally try paired delims like qq< >, q( ), ...
my %pair = qw| ( ) [ ] { } < > |;
while (my ($l, $r) = map {quotemeta} each %pair) {
last if $statement =~ s/eval\s+qq?$l(.*?)$r/$1;/;
}
}
}
# now that we've got some code containing 'use' or 'require',
# parse it! (using different entry point to save some more
# time)
......@@ -84,7 +130,7 @@ sub extract_use {
next unless $result;
foreach (split(/\s+/,$result)) {
$self->_add($_) if($_);
$self->_add($_, $eval) if($_);
}
}
......@@ -104,6 +150,22 @@ sub used {
}
sub used_in_eval {
my $self=shift;
my $key=shift;
return $self->{found_in_eval}{$key} if ($key);
return $self->{found_in_eval};
}
sub used_out_of_eval {
my $self=shift;
my $key=shift;
return $self->{found_not_in_eval}{$key} if ($key);
return $self->{found_not_in_eval};
}
sub string {
my $self=shift;
my $sep=shift || ' ';
......@@ -111,11 +173,35 @@ sub string {
}
sub string_in_eval {
my $self=shift;
my $sep=shift || ' ';
return join($sep,sort keys(%{$self->{found_in_eval}}));
}
sub string_out_of_eval {
my $self=shift;
my $sep=shift || ' ';
return join($sep,sort keys(%{$self->{found_not_in_eval}}));
}
sub array {
return keys(%{shift->{found}})
}
sub array_in_eval {
return keys(%{shift->{found_in_eval}})
}
sub array_out_of_eval {
return keys(%{shift->{found_not_in_eval}})
}
sub arrayref {
my @a=shift->array;
return \@a if @a;
......@@ -123,6 +209,20 @@ sub arrayref {
}
sub arrayref_in_eval {
my @a=shift->array_in_eval;
return \@a if @a;
return;
}
sub arrayref_out_of_eval {
my @a=shift->array_out_of_eval;
return \@a if @a;
return;
}
sub files {
return shift->{files};
}
......@@ -131,7 +231,10 @@ sub files {
sub _add {
my $self=shift;
my $found=shift;
my $eval=shift;
$self->{found}{$found}++;
$self->{found_in_eval}{$found}++ if $eval;
$self->{found_not_in_eval}{$found}++ unless $eval;
}
sub _found {
......@@ -154,7 +257,7 @@ Module::ExtractUse - Find out what modules are used
=head1 VERSION
version 0.29
version 0.31
=head1 SYNOPSIS
......@@ -175,6 +278,20 @@ version 0.29
my @used=$p->array;
my $used=$p->string;
# you can get optional modules, that is use in eval context, in the same style
my $used=$p->used_in_eval; # $used is a HASHREF
print $p->used_in_eval('strict') # true if code includes 'use strict'
my @used=$p->array_in_eval;
my $used=$p->string_in_eval;
# and mandatory modules, that is use out of eval context, in the same style, also.
my $used=$p->used_out_of_eval; # $used is a HASHREF
print $p->used_out_of_eval('strict') # true if code includes 'use strict'
my @used=$p->array_out_of_eval;
my $used=$p->string_out_of_eval;
=head1 DESCRIPTION
......@@ -239,6 +356,14 @@ hash and returns the number of times it was found during parsing.
This is the preferred accessor.
=head3 used_in_eval
Same as C<used>, except for considering in-eval-context only.
=head3 used_out_of_eval
Same as C<used>, except for considering NOT-in-eval-context only.
=head3 string
print $p->string($seperator)
......@@ -248,18 +373,42 @@ C<$seperator> or using a blank space as a default;
Module names are sorted by ascii value (i.e by C<sort>)
=head3 string_in_eval
Same as C<string>, except for considering in-eval-context only.
=head3 string_out_of_eval
Same as C<string>, except for considering NOT-in-eval-context only.
=head3 array
my @array = $p->array;
Returns an array of all used modules.
=head3 array_in_eval
Same as C<array>, except for considering in-eval-context only.
=head3 array_out_of_eval
Same as C<array>, except for considering NOT-in-eval-context only.
=head3 arrayref
my $arrayref = $p->arrayref;
Returns a reference to an array of all used modules. Surprise!
=head3 arrayref_in_eval
Same as C<array_ref>, except for considering in-eval-context only.
=head3 arrayref_out_of_eval
Same as C<array_ref>, except for considering NOT-in-eval-context only.
=head3 files
Returns the number of files parsed by the parser object.
......
This diff is collapsed.
......@@ -8,48 +8,49 @@ use Module::ExtractUse;
my @tests=
(
#1
['useSome::Module1;',undef],
['use Some::Module2;',[qw(Some::Module2)]],
["yadda yadda useless stuff;".'use Some::Module3 qw/$VERSION @EXPORT @EXPORT_OK/;',[qw(Some::Module3)]],
['use base qw(Class::DBI4 Foo::Bar5);',[qw(Class::DBI4 Foo::Bar5)]],
['if ($foo) { use Foo::Bar6; }',[qw(Foo::Bar6)]],
['useSome::Module1;',undef,undef,undef],
['use Some::Module2;',[qw(Some::Module2)],undef,[qw(Some::Module2)]],
["yadda yadda useless stuff;".'use Some::Module3 qw/$VERSION @EXPORT @EXPORT_OK/;',[qw(Some::Module3)],undef,[qw(Some::Module3)]],
['use base qw(Class::DBI4 Foo::Bar5);',[qw(Class::DBI4 Foo::Bar5)],undef,[qw(Class::DBI4 Foo::Bar5)]],
['if ($foo) { use Foo::Bar6; }',[qw(Foo::Bar6)],undef,[qw(Foo::Bar6)]],
#6
['use constant dl_ext => ".$Config{dlext}";',[qw(constant)]],
['use strict;',[qw(strict)]],
['use constant dl_ext => ".$Config{dlext}";',[qw(constant)],undef,[qw(constant)]],
['use strict;',[qw(strict)],undef,[qw(strict)]],
['use Foo8 qw/asdfsdf/;',[qw(Foo8)]],
['$use=stuff;',undef],
['abuse Stuff;',undef],
['use Foo8 qw/asdfsdf/;',[qw(Foo8)],undef,[qw(Foo8)]],
['$use=stuff;',undef,undef,undef],
['abuse Stuff;',undef,undef,undef],
#11
['package Module::ScanDeps;',undef],
['if ($foo) { require "Bar7"; }',[qw(Bar7)]],
['require "some/stuff.pl";',undef],
['require "Foo/Bar.pm9";',[qw(Foo::Bar9)]],
['require Foo10;',['Foo10']],
['package Module::ScanDeps;',undef,undef,undef],
['if ($foo) { require "Bar7"; }',[qw(Bar7)],undef,[qw(Bar7)]],
['require "some/stuff.pl";',undef,undef,undef],
['require "Foo/Bar.pm9";',[qw(Foo::Bar9)],undef,[qw(Foo::Bar9)]],
['require Foo10;',['Foo10'],undef,['Foo10']],
#16
["use Some::Module11;use Some::Other::Module12;",[qw(Some::Module11 Some::Other::Module12)]],
["use Some::Module;\nuse Some::Other::Module;",[qw(Some::Module Some::Other::Module)]],
['use vars qw/$VERSION @EXPORT @EXPORT_OK/;',[qw(vars)]],
['unless ref $obj; # use ref as $obj',undef],
['$self->_carp("$name trigger deprecated: use before_$name or after_$name instead");',undef],
["use Some::Module11;use Some::Other::Module12;",[qw(Some::Module11 Some::Other::Module12)],undef,[qw(Some::Module11 Some::Other::Module12)]],
["use Some::Module;\nuse Some::Other::Module;",[qw(Some::Module Some::Other::Module)],undef,[qw(Some::Module Some::Other::Module)]],
['use vars qw/$VERSION @EXPORT @EXPORT_OK/;',[qw(vars)],undef,[qw(vars)]],
['unless ref $obj; # use ref as $obj',undef,undef,undef],
['$self->_carp("$name trigger deprecated: use before_$name or after_$name instead");',undef,undef,undef],
#21
["use base 'Exporter1';",['Exporter1']],
['use base ("Class::DBI2");',['Class::DBI2']],
['use base "Class::DBI3";',['Class::DBI3']],
['use base qw/Class::DBI4 Foo::Bar5/;',[qw(Class::DBI4 Foo::Bar5)]],
['use base ("Class::DBI6","Foo::Bar7");',[qw(Class::DBI6 Foo::Bar7)]],
["use base 'Exporter1';",['Exporter1'],undef,['Exporter1']],
['use base ("Class::DBI2");',['Class::DBI2'],undef,['Class::DBI2']],
['use base "Class::DBI3";',['Class::DBI3'],undef,['Class::DBI3']],
['use base qw/Class::DBI4 Foo::Bar5/;',[qw(Class::DBI4 Foo::Bar5)],undef,[qw(Class::DBI4 Foo::Bar5)]],
['use base ("Class::DBI6","Foo::Bar7");',[qw(Class::DBI6 Foo::Bar7)],undef,[qw(Class::DBI6 Foo::Bar7)]],
#26
['use base "Class::DBI8","Foo::Bar9";',[qw(Class::DBI8 Foo::Bar9)]],
['eval "use Test::Pod 1.06";',['Test::Pod']],
['use base "Class::DBI8","Foo::Bar9";',[qw(Class::DBI8 Foo::Bar9)],undef,[qw(Class::DBI8 Foo::Bar9)]],
['eval "use Test::Pod 1.06";',['Test::Pod'],['Test::Pod'],undef],
[q{#!/usr/bin/perl -w
use strict;
use Test::More;
eval "use Test::Pod 1.06";
eval 'use Test::Pod::Coverage 1.06;';
plan skip_all => "Test::Pod 1.06 required for testing POD" if $@;
all_pod_files_ok();},[qw(strict Test::More Test::Pod Test::Pod::Coverage)]],
all_pod_files_ok();},[qw(strict Test::More Test::Pod Test::Pod::Coverage)],[qw(Test::Pod Test::Pod::Coverage)],[qw(strict Test::More)]],
# reported & fixed by barbie (b56e244da)
["use base qw( Data::Phrasebook::Loader::Base Data::Phrasebook::Debug );",[qw(Data::Phrasebook::Loader::Base Data::Phrasebook::Debug)]],
["use base qw( Data::Phrasebook::Loader::Base Data::Phrasebook::Debug );",[qw(Data::Phrasebook::Loader::Base Data::Phrasebook::Debug)],
undef,[qw(Data::Phrasebook::Loader::Base Data::Phrasebook::Debug)]],
# RT83569 (ribasushi)
[q[
use warnings;
......@@ -72,24 +73,41 @@ require Test::Pod;
my $generated_pod_dir = 'maint/.Generated_Pod';
Test::Pod::all_pod_files_ok( 'lib', -d $generated_pod_dir ? $generated_pod_dir : () );
],[qw(warnings strict Test::More lib DBIx::Class DBICTest Test::Pod)]],
],[qw(warnings strict Test::More lib DBIx::Class DBICTest Test::Pod)],undef,[qw(warnings strict Test::More lib DBIx::Class DBICTest Test::Pod)]],
[q[use Foo;say "Failed to load the release-testing modules we require: Bar;"],[qw(Foo)],undef,[qw(Foo)]],
[q[use Foo;say "Failed to load the release-testing modules we require: Bar";],[qw(Foo)],undef,[qw(Foo)]],
[q[use Foo;say "Failed to load the release-testing modules we require: Bar;"],[qw(Foo)],undef,[qw(Foo)]],
[q[use Data::Section -setup;],[qw(Data::Section)],undef,[qw(Data::Section)]],
[q[use Data::Section { installer => method_installer }, -setup;],[qw(Data::Section)],undef,[qw(Data::Section)]],
[q[use Data::Section -setup => { header_re => qr/^\@\@\s*(\S+)/ };],[qw(Data::Section)],undef,[qw(Data::Section)]],
['use Foo::Bar29 ();',[qw(Foo::Bar29)],undef,[qw(Foo::Bar29)]],
['use Min::Version30 1.2 ();',[qw(Min::Version30)],undef,[qw(Min::Version30)]],
['use MooseX::Types -declare => [qw(BorderStyle Component Container)];',[qw(MooseX::Types)],undef,[qw(MooseX::Types)]],
['eval { require Foo::Bar32 };',[qw(Foo::Bar32)],[qw(Foo::Bar32)],undef],
['do { use Foo::Bar33 };',[qw(Foo::Bar33)],undef,[qw(Foo::Bar33)]],
);
plan tests => (scalar @tests)+1;
plan tests => (scalar @tests)*3+1;
foreach my $t (@tests) {
my ($code,$expected)=@$t;
my ($code, @expected)=@$t;
my $p=Module::ExtractUse->new;
my $used=$p->extract_use(\$code)->arrayref;
my @used = (
$p->extract_use(\$code)->arrayref || undef,
$p->extract_use(\$code)->arrayref_in_eval || undef,
$p->extract_use(\$code)->arrayref_out_of_eval || undef,
);
if (ref($expected) eq 'ARRAY') {
cmp_bag($used,$expected);
} elsif (!defined $expected) {
is(undef,$used,'');
} else {
is($used,$expected);
for(my $i = 0; $i < @used; ++$i) {
if (ref($expected[$i]) eq 'ARRAY') {
cmp_bag($used[$i]||[],$expected[$i]);
} elsif (!defined $expected[$i]) {
is(undef,$used[$i],'');
} else {
is($used[$i],$expected[$i]);
}
}
}
......
#!/usr/bin/perl -w
use strict;
use Test::More tests=>5;
use Test::More tests=>13;
use Test::Deep;
use Test::NoWarnings;
use Module::ExtractUse;
......@@ -13,6 +13,16 @@ use Module::ExtractUse;
bag(qw(strict Test::More Test::Deep Test::NoWarnings Module::ExtractUse)),
'modules used in this test script'
);
@used=$p->extract_use($0)->array_in_eval;
cmp_deeply(\@used,
[],
'optional modules used in this test script'
);
@used=$p->extract_use($0)->array_out_of_eval;
cmp_deeply(\@used,
bag(qw(strict Test::More Test::Deep Test::NoWarnings Module::ExtractUse)),
'mandatory modules used in this test script'
);
}
# test Module::ExtractUse
......@@ -22,12 +32,28 @@ use Module::ExtractUse;
cmp_deeply($p->arrayref,
bag(qw(strict warnings Pod::Strip Parse::RecDescent Module::ExtractUse::Grammar Carp 5.008)),
'modules used in this Module::ExtractUsed');
cmp_deeply([$p->arrayref_in_eval],
[],
'optional modules used in this Module::ExtractUsed');
cmp_deeply($p->arrayref_out_of_eval,
bag(qw(strict warnings Pod::Strip Parse::RecDescent Module::ExtractUse::Grammar Carp 5.008)),
'mandatory modules used in this Module::ExtractUsed');
my $used=$p->used;
is($used->{'strict'},1,'strict via hash lookup');
is($p->used('strict'),1,'strict via used method');
my $used_in_eval=$p->used_in_eval;
is(!$used_in_eval->{'strict'},1,'strict via in-eval hash lookup');
is(!$p->used_in_eval('strict'),1,'strict via used_in_eval method');
my $used_out_of_eval=$p->used_out_of_eval;
is($used_out_of_eval->{'strict'},1,'strict via out-of-eval hash lookup');
is($p->used_out_of_eval('strict'),1,'strict via used_out_of_eval method');
}
......
#!/usr/bin/perl -w
use strict;
use Test::More tests => 7;
use Test::More tests => 8;
use Module::ExtractUse;
......@@ -73,3 +73,16 @@ is $p->extract_use(\(<<'CODE'))->string, 'Apache::DBI';
require Apache::DBI
CODE
}
# Handle trailing comments which become comment lines after the split on
# ';'.
{
my $p = Module::ExtractUse->new;
is $p->extract_use(\(<<'CODE'))->string, '5.008 strict warnings';
use 5.008; # Because we want to
# Another comment
use strict;
use warnings;
CODE
}
use Test::More tests => 9;
use strict;
use warnings;
use Module::ExtractUse;
{
my $semi = 'eval "use Test::Pod 1.00;";';
my $p = Module::ExtractUse->new;
$p->extract_use( \$semi );
ok( $p->used( 'Test::Pod' ) );
}
{
my $nosemi = "eval 'use Test::Pod 1.00';";
my $p = Module::ExtractUse->new;
$p->extract_use( \$nosemi );
ok( $p->used( 'Test::Pod' ) );
}
use Test::More tests => 48;
use strict;
use warnings;
use Module::ExtractUse;
{
my $semi = 'eval "use Test::Pod 1.00;";';
my $p = Module::ExtractUse->new;
$p->extract_use( \$semi );
ok( $p->used( 'Test::Pod' ) );
ok( $p->used_in_eval( 'Test::Pod' ) );
ok(!$p->used_out_of_eval( 'Test::Pod' ) );
}
{
my $nosemi = "eval 'use Test::Pod 1.00';";
my $p = Module::ExtractUse->new;
$p->extract_use( \$nosemi );
ok( $p->used( 'Test::Pod' ) );
ok( $p->used_in_eval( 'Test::Pod' ) );
ok(!$p->used_out_of_eval( 'Test::Pod' ) );
}
{
my $qq = "eval qq{use Test::Pod 1.00}";
my $p = Module::ExtractUse->new;
$p->extract_use( \$qq );
ok( $p->used( 'Test::Pod' ), 'qq brace' );
ok( $p->used_in_eval( 'Test::Pod' ), 'qq brace' );
ok(!$p->used_out_of_eval( 'Test::Pod' ), 'qq brace' );
}
{
......@@ -33,6 +39,8 @@ use Module::ExtractUse;
my $p = Module::ExtractUse->new;
$p->extract_use( \$qq );
ok( $p->used( 'Test::Pod' ), 'qq plus' );
ok( $p->used_in_eval( 'Test::Pod' ), 'qq plus' );
ok(!$p->used_out_of_eval( 'Test::Pod' ), 'qq plus' );
}
{
......@@ -40,6 +48,8 @@ use Module::ExtractUse;
my $p = Module::ExtractUse->new;
$p->extract_use( \$qq );
ok( $p->used( 'Test::Pod' ), 'qq paren' );
ok( $p->used_in_eval( 'Test::Pod' ), 'qq paren' );
ok(!$p->used_out_of_eval( 'Test::Pod' ), 'qq paren' );
}
{
......@@ -47,6 +57,8 @@ use Module::ExtractUse;
my $p = Module::ExtractUse->new;
$p->extract_use( \$q );
ok( $p->used( 'Test::Pod' ), 'q angle' );
ok( $p->used_in_eval( 'Test::Pod' ), 'q angle' );
ok(!$p->used_out_of_eval( 'Test::Pod' ), 'q angle' );
}
{
......@@ -54,25 +66,83 @@ use Module::ExtractUse;
my $p = Module::ExtractUse->new;
$p->extract_use( \$q );
ok( $p->used( 'Test::Pod' ), 'q slash' );
ok( $p->used_in_eval( 'Test::Pod' ), 'q slash' );
ok(!$p->used_out_of_eval( 'Test::Pod' ), 'q slash' );
}
# reported by DAGOLDEN@cpan.org as [rt.cpan.org #19302]
{
my $varversion = q{my $ver=1.22;
eval "use Test::Pod $ver;"};
my $p = Module::ExtractUse->new;
$p->extract_use( \$varversion );
ok( $p->used( 'Test::Pod' ) );
ok( $p->used_in_eval( 'Test::Pod' ) );
ok(!$p->used_out_of_eval( 'Test::Pod' ) );
}
{
my $varversion = q{my $ver=1.22;
eval 'use Test::Pod $ver';};
my $p = Module::ExtractUse->new;
$p->extract_use( \$varversion );
ok( $p->used( 'Test::Pod' ) );
ok( $p->used_in_eval( 'Test::Pod' ) );
ok(!$p->used_out_of_eval( 'Test::Pod' ) );