From f5203e1f7b935bab681a057d6feb080b07d98118 Mon Sep 17 00:00:00 2001 From: Christian Walde Date: Mon, 25 Nov 2024 15:14:42 +0100 Subject: [PATCH] allow experimental to declare signatures --- lib/PPI/Statement/Include.pm | 4 ++++ t/feature_tracking.t | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/PPI/Statement/Include.pm b/lib/PPI/Statement/Include.pm index 808d181e..1564cd8d 100644 --- a/lib/PPI/Statement/Include.pm +++ b/lib/PPI/Statement/Include.pm @@ -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 }; } diff --git a/t/feature_tracking.t b/t/feature_tracking.t index f36577bf..513f430f 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 => 11 + ( $ENV{AUTHOR_TESTING} ? 1 : 0 ); +use Test::More tests => 13 + ( $ENV{AUTHOR_TESTING} ? 1 : 0 ); use B 'perlstring'; @@ -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" );