From 85d0109ba84c44110ba8dfc7efe0129f02e0a5c7 Mon Sep 17 00:00:00 2001 From: Christian Walde Date: Mon, 25 Nov 2024 13:03:34 +0100 Subject: [PATCH] cpan --- lib/PPI/Statement/Include.pm | 9 ++++++ t/feature_tracking.t | 56 +++++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/lib/PPI/Statement/Include.pm b/lib/PPI/Statement/Include.pm index 008dea70..cb0c79cb 100644 --- a/lib/PPI/Statement/Include.pm +++ b/lib/PPI/Statement/Include.pm @@ -47,6 +47,7 @@ L, L and L methods. use strict; use version 0.77 (); +use Safe::Isa '$_call_if_object'; use PPI::Statement (); use PPI::Statement::Include::Perl6 (); @@ -286,6 +287,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; } diff --git a/t/feature_tracking.t b/t/feature_tracking.t index 7c126586..f9d45158 100644 --- a/t/feature_tracking.t +++ b/t/feature_tracking.t @@ -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'; @@ -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 {