Skip to content

Commit

Permalink
cpan
Browse files Browse the repository at this point in the history
  • Loading branch information
wchristian committed Nov 25, 2024
1 parent 173ed64 commit fc4da76
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
9 changes: 9 additions & 0 deletions lib/PPI/Statement/Include.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ L<PPI::Statement>, L<PPI::Node> and L<PPI::Element> methods.
use strict;

use version 0.77 ();
use Safe::Isa '$_call_if_object';

use PPI::Statement ();
use PPI::Statement::Include::Perl6 ();
Expand Down Expand Up @@ -285,6 +286,14 @@ sub feature_mods {
elsif ( $self->module eq "Syntax::Keyword::Try" ) {
return { try => $on_or_off ? "Syntax::Keyword::Try" : 0 };
}
elsif ( $self->module eq "Mojolicious::Lite" ) {
my $wants_signatures = grep /-signatures/, $self->arguments;
return { signatures => $wants_signatures ? "perl" : 0 };
}
elsif ( $self->module eq "Modern::Perl" ) {
my $v = $self->module_version->$_call_if_object("literal") || 0;
return { signatures => $v >= 2023 ? "perl" : 0 };
}

if ( my $custom = $self->_custom_feature_includes->{ $self->module } ) #
{ return $custom; }
Expand Down
56 changes: 55 additions & 1 deletion t/feature_tracking.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use lib 't/lib';
use PPI::Test::pragmas;
use Test::More tests => 9 + ( $ENV{AUTHOR_TESTING} ? 1 : 0 );
use Test::More tests => 11 + ( $ENV{AUTHOR_TESTING} ? 1 : 0 );

use B 'perlstring';

Expand Down Expand Up @@ -330,6 +330,60 @@ END_PERL
"callback for complex custom boilerplate modules";
}

CPAN_MOJOLICIOUS_LITE: {
test_document
<<'END_PERL',
use Mojolicious::Lite -signatures;
sub meep($) {}
END_PERL
[
'PPI::Statement::Include', 'use Mojolicious::Lite -signatures;',
'PPI::Token::Word', 'use',
'PPI::Token::Word', 'Mojolicious::Lite',
'PPI::Token::Word', '-signatures',
'PPI::Token::Structure', ';',
'PPI::Statement::Sub', 'sub meep($) {}',
'PPI::Token::Word', 'sub',
'PPI::Token::Word', 'meep',
'PPI::Structure::Signature', '($)',
'PPI::Token::Structure', '(',
'PPI::Statement::Expression', '$',
'PPI::Token::Symbol', '$',
'PPI::Token::Structure', ')',
'PPI::Structure::Block', '{}',
'PPI::Token::Structure', '{',
'PPI::Token::Structure', '}',
],
"simple custom boilerplate modules";
}

CPAN_MODERN_PERL: {
test_document
<<'END_PERL',
use Modern::Perl 2023;
sub meep($) {}
END_PERL
[
'PPI::Statement::Include', 'use Modern::Perl 2023;',
'PPI::Token::Word', 'use',
'PPI::Token::Word', 'Modern::Perl',
'PPI::Token::Number', '2023',
'PPI::Token::Structure', ';',
'PPI::Statement::Sub', 'sub meep($) {}',
'PPI::Token::Word', 'sub',
'PPI::Token::Word', 'meep',
'PPI::Structure::Signature', '($)',
'PPI::Token::Structure', '(',
'PPI::Statement::Expression', '$',
'PPI::Token::Symbol', '$',
'PPI::Token::Structure', ')',
'PPI::Structure::Block', '{}',
'PPI::Token::Structure', '{',
'PPI::Token::Structure', '}',
],
"simple custom boilerplate modules";
}

### TODO from ppi_token_unknown.t , deduplicate

sub one_line_explain {
Expand Down

0 comments on commit fc4da76

Please sign in to comment.