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 Dec 26, 2024
1 parent a26eefc commit f5203e1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/PPI/Statement/Include.pm
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ 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/, $self->_decompose_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 => 13 + ( $ENV{AUTHOR_TESTING} ? 1 : 0 );

use B 'perlstring';

Expand Down Expand Up @@ -388,6 +388,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";
}


ok( PPI::Tokenizer->new( \"d()" )->all_tokens, "bare tokenizer auto-vivifies document object" );

Expand Down

0 comments on commit f5203e1

Please sign in to comment.