diff --git a/lib/Sub/Exporter.pm b/lib/Sub/Exporter.pm index f06f6cb..687e9fc 100644 --- a/lib/Sub/Exporter.pm +++ b/lib/Sub/Exporter.pm @@ -1,5 +1,6 @@ -use v5.12.0; +use v5.20.0; use warnings; +use stable 'postderef'; package Sub::Exporter; # ABSTRACT: a sophisticated exporter for custom-built routines @@ -442,7 +443,7 @@ sub _expand_groups { : $groups[$i][1]{-as} ? $prefix . $groups[$i][1]{-as} . $suffix : $prefix . $groups[$i][0] . $suffix; - $groups[$i][1] = { %{ $groups[$i][1] }, %merge, -as => $as }; + $groups[$i][1] = { $groups[$i][1]->%*, %merge, -as => $as }; } } } @@ -695,7 +696,7 @@ sub _rewrite_build_config { $config->{groups}{default} ||= []; # by default, build an all-inclusive 'all' group - $config->{groups}{all} ||= [ keys %{ $config->{exports} } ]; + $config->{groups}{all} ||= [ keys $config->{exports}->%* ]; $config->{generator} ||= \&default_generator; $config->{installer} ||= \&default_installer; @@ -840,7 +841,7 @@ Passed arguments are: sub default_generator { my ($arg) = @_; - my ($class, $name, $generator) = @$arg{qw(class name generator)}; + my ($class, $name, $generator) = $arg->@{qw(class name generator)}; if (not defined $generator) { my $code = $class->can($name) @@ -881,7 +882,7 @@ sub default_installer { my ($arg, $to_export) = @_; for (my $i = 0; $i < @$to_export; $i += 2) { - my ($as, $code) = @$to_export[ $i, $i+1 ]; + my ($as, $code) = $to_export->@[ $i, $i+1 ]; # Allow as isa ARRAY to push onto an array? # Allow into isa HASH to install name=>code into hash? @@ -944,10 +945,10 @@ sub _setup { my ($value, $arg) = @_; if (ref $value eq 'HASH') { - push @{ $arg->{import_args} }, [ _import => { -as => 'import', %$value } ]; + push $arg->{import_args}->@*, [ _import => { -as => 'import', %$value } ]; return 1; } elsif (ref $value eq 'ARRAY') { - push @{ $arg->{import_args} }, + push $arg->{import_args}->@*, [ _import => { -as => 'import', exports => $value } ]; return 1; } diff --git a/lib/Sub/Exporter/Util.pm b/lib/Sub/Exporter/Util.pm index e0619a7..f02e0e7 100644 --- a/lib/Sub/Exporter/Util.pm +++ b/lib/Sub/Exporter/Util.pm @@ -1,5 +1,6 @@ -use v5.12.0; +use v5.20.0; use warnings; +use stable 'postderef'; package Sub::Exporter::Util; # ABSTRACT: utilities to make Sub::Exporter easier @@ -104,7 +105,7 @@ sub curry_chain { sub { my $next = $class; - for my $i (0 .. $#$pairs) { + for my $i (0 .. $pairs->$#*) { my $pair = $pairs->[ $i ]; unless (Params::Util::_INVOCANT($next)) { ## no critic Private @@ -114,7 +115,7 @@ sub curry_chain { my ($method, $args) = @$pair; - if ($i == $#$pairs) { + if ($i == $pairs->$#*) { return $next->$method($args ? @$args : ()); } else { $next = $next->$method($args ? @$args : ()); @@ -197,7 +198,7 @@ sub merge_col { my ($class, $name, $arg, $col) = @_; my $merged_arg = exists $col->{$default_name} - ? { %{ $col->{$default_name} }, %$arg } + ? { $col->{$default_name}->%*, %$arg } : $arg; if (Params::Util::_CODELIKE($gen)) { ## no critic Private @@ -300,7 +301,7 @@ sub like { while (my ($re, $opt) = splice @values, 0, 2) { Carp::croak "given pattern for regex group generater is not a Regexp" unless eval { $re->isa('Regexp') }; - my @exports = keys %{ $arg->{config}->{exports} }; + my @exports = keys $arg->{config}->{exports}->%*; my @matching = grep { $_ =~ $re } @exports; my %merge = $opt ? %$opt : (); @@ -309,7 +310,7 @@ sub like { for my $name (@matching) { my $as = $prefix . $name . $suffix; - push @{ $arg->{import_args} }, [ $name => { %merge, -as => $as } ]; + push $arg->{import_args}->@*, [ $name => { %merge, -as => $as } ]; } } diff --git a/t/col-init.t b/t/col-init.t index 52aa8ea..4aceb01 100644 --- a/t/col-init.t +++ b/t/col-init.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE @@ -25,7 +26,7 @@ my $config = { collectors => [ INIT => sub { my ($value, $arg) = @_; - return 0 if @{$arg->{import_args}}; # in other words, fail if args + return 0 if $arg->{import_args}->@*; # in other words, fail if args $_[0] = [ $counter++ ]; return 1; }, @@ -36,7 +37,7 @@ $config->{$_} = mkopt_hash($config->{$_}) for qw(exports collectors); { my $collection = Sub::Exporter::_collect_collections( - $config, + $config, [ ], 'main', ); @@ -51,7 +52,7 @@ $config->{$_} = mkopt_hash($config->{$_}) for qw(exports collectors); { my $collection = eval { Sub::Exporter::_collect_collections( - $config, + $config, [ [ handsaw => undef ] ], 'main', ); diff --git a/t/collection.t b/t/collection.t index 35dbb48..ed5bbce 100644 --- a/t/collection.t +++ b/t/collection.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE @@ -44,7 +45,7 @@ $config->{$_} = mkopt_hash($config->{$_}) { my $collection = Sub::Exporter::_collect_collections( - $config, + $config, [ [ circsaw => undef ], [ defaults => { foo => 1, bar => 2 } ] ], 'main', ); @@ -58,7 +59,7 @@ $config->{$_} = mkopt_hash($config->{$_}) { my $collection = Sub::Exporter::_collect_collections( - $config, + $config, [ [ sets_own_value => undef ] ], 'main', ); diff --git a/t/expand-group.t b/t/expand-group.t index a3295d2..f147716 100644 --- a/t/expand-group.t +++ b/t/expand-group.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE @@ -161,7 +162,7 @@ my @single_tests = ( for my $test (@single_tests) { my ($label, $given, $expected) = @$test; - + my @got = Sub::Exporter::_expand_group( 'Class', $config, @@ -174,7 +175,7 @@ for my $test (@single_tests) { for my $test (@single_tests) { my ($label, $given, $expected) = @$test; - + my $got = Sub::Exporter::_expand_groups( 'Class', $config, @@ -202,7 +203,7 @@ my @multi_tests = ( for my $test (@multi_tests) { my ($label, $given, $expected) = @$test; - + my $got = Sub::Exporter::_expand_groups( 'Class', $config, diff --git a/t/faux-export.t b/t/faux-export.t index 1d07a60..7248fc0 100644 --- a/t/faux-export.t +++ b/t/faux-export.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE @@ -66,7 +67,7 @@ my $config = { $code->('Tools::Power', ':cutters'); exports_ok( $exports, - [ [ circsaw => {} ], [ handsaw => {} ], [ circsaw => {} ] ], + [ [ circsaw => {} ], [ handsaw => {} ], [ circsaw => {} ] ], "group with two export instances of one export", ); diff --git a/t/gen-callable.t b/t/gen-callable.t index d17705a..424b598 100644 --- a/t/gen-callable.t +++ b/t/gen-callable.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; use Test::More tests => 8; diff --git a/t/group-generator.t b/t/group-generator.t index 5bfecf0..1cd0656 100644 --- a/t/group-generator.t +++ b/t/group-generator.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE @@ -63,7 +64,7 @@ my @single_tests = ( for my $test (@single_tests) { my ($label, $given, $expected) = @$test; - + my @got = Sub::Exporter::_expand_group( 'Class', $config, @@ -80,7 +81,7 @@ for my $test (@single_tests) { for my $test (@single_tests) { my ($label, $given, $expected) = @$test; - + my $got = Sub::Exporter::_expand_groups( 'Class', $config, @@ -100,7 +101,7 @@ my @multi_tests = ( for my $test (@multi_tests) { my ($label, $given, $expected) = @$test; - + my $got = Sub::Exporter::_expand_groups( 'Class', $config, @@ -157,7 +158,7 @@ like($@, name => $_, class => 'Class', group => 'generated', - arg => { xyz => 1 }, + arg => { xyz => 1 }, collection => { col1 => { value => 2 } }, }, "generated foo does what we expect", @@ -182,7 +183,7 @@ like($@, name => $_, class => 'Class', group => 'generated', - arg => { xyz => 1 }, + arg => { xyz => 1 }, collection => { col1 => { value => 2 } }, }, "generated foo (via nested group) does what we expect", diff --git a/t/inherited.t b/t/inherited.t index 005380b..5f9f0f5 100644 --- a/t/inherited.t +++ b/t/inherited.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE diff --git a/t/into-level.t b/t/into-level.t index 1066fec..eccc322 100644 --- a/t/into-level.t +++ b/t/into-level.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE @@ -11,14 +12,14 @@ exporter. use Test::More tests => 14; -BEGIN { - use_ok('Sub::Exporter'); +BEGIN { + use_ok('Sub::Exporter'); } BEGIN { package Test::SubExport::FROM; use strict; - use warnings; + use warnings; use Sub::Exporter -setup => { exports => [ qw(A B) ], groups => { @@ -31,13 +32,13 @@ BEGIN { sub A { 'A' } sub B { 'B' } - 1; + 1; } BEGIN { package Test::SubExport::HAS_DEFAULT_INTO_LEVEL; use strict; - use warnings; + use warnings; use Sub::Exporter -setup => { exports => [ qw(C) ], into_level => 1, @@ -45,7 +46,7 @@ BEGIN { sub C { 'C' } - 1; + 1; } BEGIN { diff --git a/t/real-export-groupgen.t b/t/real-export-groupgen.t index 9ad3d7b..ca8c4fe 100644 --- a/t/real-export-groupgen.t +++ b/t/real-export-groupgen.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE @@ -39,7 +40,7 @@ for my $routine (qw(foo bar)) { name => $routine, class => 'Test::SubExporter::GroupGen', group => 'generated', - arg => { xyz => 1 }, + arg => { xyz => 1 }, collection => { col1 => { value => 2 } }, }, "generated $routine does what we expect", @@ -52,7 +53,7 @@ for my $routine (qw(foo bar)) { name => $routine, class => 'Test::SubExporter::GroupGen', group => 'generated', - arg => { xyz => 5 }, + arg => { xyz => 5 }, collection => { col1 => { value => 2 } }, }, "generated $five does what we expect", @@ -65,7 +66,7 @@ is_deeply( name => 'baz', class => 'Test::SubExporter::GroupGen', group => 'symbolic', - arg => { xyz => 2 }, + arg => { xyz => 2 }, collection => { col1 => { value => 2 } }, }, "parent class's generated baz does what we expect", @@ -77,7 +78,7 @@ is_deeply( name => 'baz-sc', class => 'Test::SubExporter::GroupGenSubclass', group => 'symbolic', - arg => { xyz => 4 }, + arg => { xyz => 4 }, collection => { col1 => { value => 3 } }, }, "inheriting class's generated baz does what we expect", diff --git a/t/real-export-href.t b/t/real-export-href.t index 6f97992..6d43a08 100644 --- a/t/real-export-href.t +++ b/t/real-export-href.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE diff --git a/t/real-export-setup.t b/t/real-export-setup.t index 5d4f8f7..e6d3ddf 100644 --- a/t/real-export-setup.t +++ b/t/real-export-setup.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE diff --git a/t/util-curry.t b/t/util-curry.t index 3434147..1d29c0c 100644 --- a/t/util-curry.t +++ b/t/util-curry.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; use Test::More tests => 10; BEGIN { use_ok("Sub::Exporter"); } @@ -18,7 +19,7 @@ BEGIN { use_ok("Sub::Exporter"); } sub new { bless { key => "value" } => $_[0] } sub return_invocant { return $_[0] } } - + BEGIN { package Thing::Subclass; our @ISA = qw(Thing); diff --git a/t/util-currychain.t b/t/util-currychain.t index 2583047..3fb228d 100644 --- a/t/util-currychain.t +++ b/t/util-currychain.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; use Test::More tests => 4; diff --git a/t/util-like.t b/t/util-like.t index 3e72a47..56273c9 100644 --- a/t/util-like.t +++ b/t/util-like.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; use Test::More tests => 11; BEGIN { use_ok("Sub::Exporter"); } diff --git a/t/util-merge.t b/t/util-merge.t index 4b0bbb4..a6a9ee6 100644 --- a/t/util-merge.t +++ b/t/util-merge.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; use Test::More tests => 8; BEGIN { use_ok("Sub::Exporter"); } diff --git a/t/util-mixin.t b/t/util-mixin.t index b7cf44e..eaf96cd 100644 --- a/t/util-mixin.t +++ b/t/util-mixin.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; use Test::More; @@ -96,9 +97,9 @@ for (0 .. $#pkg) { my @super = map {; no strict 'refs'; [ @{$_ . "::ISA"} ] } @pkg; for my $x (0 .. $#pkg) { - is(@{$super[$x]}, 1, "one parent for $pkg[$x]: @{$super[$x]}"); + is($super[$x]->@*, 1, "one parent for $pkg[$x]: $super[$x]->@*"); for my $y (($x + 1) .. $#pkg) { - isnt("@{$super[$x]}", "@{$super[$y]}", "parent($x) ne parent($y)") + isnt("$super[$x]->@*", "$super[$y]->@*", "parent($x) ne parent($y)") } } diff --git a/t/util-namemap.t b/t/util-namemap.t index 65cf762..0c1714f 100644 --- a/t/util-namemap.t +++ b/t/util-namemap.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; use Test::More skip_all => 'not actually offerring this feature yet'; diff --git a/t/valid-config.t b/t/valid-config.t index 8351154..f6a2b43 100644 --- a/t/valid-config.t +++ b/t/valid-config.t @@ -1,6 +1,7 @@ #!perl -T -use strict; +use v5.20.0; use warnings; +use stable 'postderef'; =head1 TEST PURPOSE @@ -43,7 +44,7 @@ like( "into and into_level are mutually exclusive (in setup_exporter)" ); -eval { +eval { Sub::Exporter::build_exporter({})->( Class => { into => 'Your::Face', @@ -70,4 +71,3 @@ like( qr(^into and into_level may not both be supplied to exporter), "can't use one name in exports and collectors" ); -