Skip Menu |

This queue is for tickets about the Module-ExtractUse CPAN distribution.

Report information
The Basics
Id: 50723
Status: resolved
Priority: 0/
Queue: Module-ExtractUse

People
Owner: Nobody in particular
Requestors: cjm [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.23
Fixed in: (no value)



Subject: [PATCH] make import_list more inclusive
The attached patch allows more variation in the import_list, which allows it to pick up modules that are currently ignored. This fixes RT#44538 (but it fixes more than just that bug). (It also includes the patch from RT#42006, along with tests for that bug.) The following syntaxes are now supported (and tested): use Foo::Bar29 (); use Min::Version30 1.2 (); use MooseX::Types -declare => [qw(BorderStyle Component Container)]; eval { require Foo::Bar32 }; do { use Foo::Bar33 }; (Ok, I'm not sure that there's much point in that last syntax, but it is valid Perl, and wasn't detected before.) It also fixes the test script to better report errors. (It didn't tell you what module was expected when no modules were found.)
Subject: cjm.patch
--- lib/Module/ExtractUse/grammar 2008-04-26 15:25:00.000000000 -0500 +++ lib/Module/ExtractUse/grammar 2009-10-21 15:57:55.900500452 -0500 @@ -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 @@ # 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 @@ { $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 []> + | + /-?\w+/ { $return=$item[1] } comma_list_item: comma list_item { $return=$item{list_item} } --- t/10_basic.t 2008-04-26 15:25:00.000000000 -0500 +++ t/10_basic.t 2009-10-21 15:59:27.162735137 -0500 @@ -48,6 +48,12 @@ 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)]], + ['use Foo::Bar29 ();',[qw(Foo::Bar29)]], + ['use Min::Version30 1.2 ();',[qw(Min::Version30)]], +#31 + ['use MooseX::Types -declare => [qw(BorderStyle Component Container)];',[qw(MooseX::Types)]], + ['eval { require Foo::Bar32 };',[qw(Foo::Bar32)]], + ['do { use Foo::Bar33 };',[qw(Foo::Bar33)]], ); @@ -60,7 +66,7 @@ my $used=$p->extract_use(\$code)->arrayref; if (ref($expected) eq 'ARRAY') { - cmp_bag($used,$expected); + cmp_bag($used || [], $expected); } elsif (!defined $expected) { is(undef,$used,''); } else {
This has been applied in 0.31. Thanks. On Thu Oct 22 06:21:32 2009, CJM wrote: Show quoted text
> The attached patch allows more variation in the import_list, which > allows it to pick up modules that are currently ignored. This fixes > RT#44538 (but it fixes more than just that bug). (It also includes the > patch from RT#42006, along with tests for that bug.) > > The following syntaxes are now supported (and tested): > > use Foo::Bar29 (); > use Min::Version30 1.2 (); > use MooseX::Types -declare => [qw(BorderStyle Component Container)]; > eval { require Foo::Bar32 }; > do { use Foo::Bar33 }; > > (Ok, I'm not sure that there's much point in that last syntax, but it is > valid Perl, and wasn't detected before.) > > It also fixes the test script to better report errors. (It didn't tell > you what module was expected when no modules were found.)