Skip to content

Commit

Permalink
allow experimental to declare signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
wchristian committed Nov 25, 2024
1 parent 7783070 commit 036aef5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/PPI/Statement/Include.pm
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ sub feature_mods {
my $v = $self->module_version->$_call_if_object("literal") || 0;
return { signatures => $v >= 2023 ? "perl" : 0 };
}
elsif ( $self->module eq "experimental" ) {
my $wants_signatures = #
grep /signatures/, map $_->literal, $self->arguments;
return { signatures => $wants_signatures ? "perl" : 0 };
}
elsif ( $self->module eq "Syntax::Keyword::Try" ) {
return { try => $on_or_off ? "Syntax::Keyword::Try" : 0 };
}
Expand Down
29 changes: 28 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 => 11 + ( $ENV{AUTHOR_TESTING} ? 1 : 0 );
use Test::More tests => 12 + ( $ENV{AUTHOR_TESTING} ? 1 : 0 );

use B 'perlstring';

Expand Down Expand Up @@ -384,6 +384,33 @@ END_PERL
"simple custom boilerplate modules";
}

CPAN_EXPERIMENTAL: {
test_document
<<'END_PERL',
use experimental qw( signatures );
sub meep($) {}
END_PERL
[
'PPI::Statement::Include', 'use experimental qw( signatures );',
'PPI::Token::Word', 'use',
'PPI::Token::Word', 'experimental',
'PPI::Token::QuoteLike::Words', 'qw( 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";
}

### TODO from ppi_token_unknown.t , deduplicate

sub one_line_explain {
Expand Down

0 comments on commit 036aef5

Please sign in to comment.