diff --git a/Changes b/Changes index 45c3173..a0b226e 100644 --- a/Changes +++ b/Changes @@ -1,7 +1,7 @@ Revision history for Perl extension Util::H2O. 0.26 not yet released - - ... + - Increased minimum required Perl version to 5.8.9 0.24 Wed, Dec 13 2023 commit 10a8b75ad51a195fc8c8a7a5e8633bec4bf6eb8b - fix a bug where o2h would die on scalars that looked like options diff --git a/Makefile.PL b/Makefile.PL index e3b5bb5..cf198fd 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -6,13 +6,13 @@ WriteMakefile( LICENSE => 'perl_5', VERSION_FROM => 'lib/Util/H2O.pm', ABSTRACT_FROM => 'lib/Util/H2O.pm', - MIN_PERL_VERSION => '5.6.0', + MIN_PERL_VERSION => '5.8.9', META_MERGE => { 'meta-spec' => { version => 2 }, provides => { 'Util::H2O' => { file => 'lib/Util/H2O.pm', - version => '0.24', + version => '0.26', }, }, resources => { @@ -34,9 +34,7 @@ WriteMakefile( 'Carp' => 0, 'Exporter' => '5.58', 'Symbol' => 0, - ( $] ge '5.008009' ? ( - 'Hash::Util' => '0.06', - ):()), + 'Hash::Util' => '0.06', }, TEST_REQUIRES => { 'Test::More' => '1.302096', diff --git a/README.md b/README.md index 5f4a165..62b9adf 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ instead of `make`. Dependencies ------------ -Requirements: Perl v5.6 or higher (a more current version is *strongly* +Requirements: Perl v5.8.9 or higher (a more current version is *strongly* recommended) and several of its core modules; users of older Perls may need to upgrade some core modules. diff --git a/lib/Util/H2O.pm b/lib/Util/H2O.pm index 36fee90..ba06910 100644 --- a/lib/Util/H2O.pm +++ b/lib/Util/H2O.pm @@ -2,9 +2,10 @@ package Util::H2O; use warnings; use strict; -use Exporter 'import'; use Carp; +use Exporter 'import'; use Symbol qw/delete_package/; +use Hash::Util qw/ lock_ref_keys lock_hashref /; =head1 Name @@ -46,21 +47,6 @@ our $VERSION = '0.26'; our @EXPORT = qw/ h2o /; ## no critic (ProhibitAutomaticExportation) our @EXPORT_OK = qw/ o2h /; -BEGIN { - # lock_ref_keys wasn't available until Hash::Util 0.06 / Perl v5.8.9 - # (note the following will probably also fail on the Perl v5.9 dev releases) - # uncoverable branch false - # uncoverable condition false - if ( $] ge '5.008009' ) { - require Hash::Util; - Hash::Util->import(qw/ lock_ref_keys lock_hashref /) } - else { - *lock_ref_keys = *lock_hashref = sub { - carp "this Perl is too old to lock the hash"; # uncoverable statement - }; # uncoverable statement - } -} - =head1 Description This module allows you to turn hashrefs into objects, so that instead @@ -223,11 +209,10 @@ Keysets of objects created by the constructor generated by the C<-new> option are also locked. Versions of this module before v0.12 did not lock the keysets of new objects. -Note that on really old Perls, that is, before Perl v5.8.9, -L and its C are not available, so the hash -is never locked on those versions of Perl. Versions of this module -before v0.06 did not lock the keyset. +Versions of this module before v0.06 did not lock the keyset. Versions of this module as of v0.12 issue a warning on old Perls. +(Versions of this module before v0.26 were compatible with Perls older than v5.8.9, +where L and its C were not available.) =item C<-nolock> @@ -244,9 +229,7 @@ also use the C<-new> option - the additional keys will then only be useful as arguments to the constructor. This option can't be used with C<-nolock> or C<< -lock=>0 >>. -This option was added in v0.12. Using this option will not work and cause a -warning when used on really old Perls (before v5.8.9), because this -functionality was not yet available there. +This option was added in v0.12. =item C<< -pass => "ref" I "undef" >> diff --git a/t/Util-H2O.t b/t/Util-H2O.t index 241a3ee..4baf5cf 100755 --- a/t/Util-H2O.t +++ b/t/Util-H2O.t @@ -20,7 +20,7 @@ L. =cut -use Test::More tests => 343; +use Test::More tests => 339; use Scalar::Util qw/blessed/; use Symbol qw/delete_package/; @@ -33,9 +33,6 @@ diag "This is Perl $] at $^X on $^O"; BEGIN { use_ok 'Util::H2O' } is $Util::H2O::VERSION, '0.26'; -diag "If all tests pass, you can ignore the \"this Perl is too old\" warnings" - if $] lt '5.008009'; - my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars) { @@ -86,11 +83,8 @@ my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars) } { my $o = h2o -recurse, { foo => { bar => "quz" } }; - SKIP: { - skip "Won't work on old Perls", 2 if $] lt '5.008009'; - ok exception { $o->{abc} = 123 }; - ok exception { $o->foo->{def} = 456 }; - } + ok exception { $o->{abc} = 123 }; + ok exception { $o->foo->{def} = 456 }; my $o2 = h2o -recurse, -nolock, { foo => { bar => "quz" } }; $o2->{abc} = 123; $o2->foo->{def} = 456; @@ -153,11 +147,8 @@ my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars) # -arrays + -lock + -ro { my $o = h2o -arrays, -lock=>1, -ro, { abc => [ { def => 'ghi' } ] }; - SKIP: { - skip "Won't work on old Perls", 2 if $] lt '5.008009'; - ok exception { my $x = $o->{zzz} }; - ok exception { my $y = $o->{abc}[0]{def}{yyy} }; - } + ok exception { my $x = $o->{zzz} }; + ok exception { my $y = $o->{abc}[0]{def}{yyy} }; is $o->abc->[0]->def, 'ghi'; ok exception { $o->abc(123) }; ok exception { $o->abc->[0]->def(123) }; @@ -205,11 +196,8 @@ my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars) # o2h + -lock + -ro { my $o = h2o -recurse, -lock=>1, -ro, { abc => { def => { ghi => 555 } } }; - SKIP: { - skip "Won't work on old Perls", 2 if $] lt '5.008009'; - ok exception { my $x = $o->{zzz} }; - ok exception { my $y = $o->{abc}{def}{yyy} }; - } + ok exception { my $x = $o->{zzz} }; + ok exception { my $y = $o->{abc}{def}{yyy} }; my $h = o2h $o; is ref $h, 'HASH'; is ref $h->{abc}{def}, 'HASH'; @@ -268,10 +256,7 @@ my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars) is $o->y, 222; is_deeply [sort keys %$o], [qw/ x /]; is $o->{x}, 111; - SKIP: { - skip "Won't work on old Perls", 1 if $] lt '5.008009'; - ok exception { my $x = $o->{y} }; - } + ok exception { my $x = $o->{y} }; } { my $o = h2o -meth, { x=>111, y=>sub{222} }, qw/y/; @@ -402,11 +387,8 @@ sub checksym { is $n3->abc, 444; like exception { Quz->new(abc=>4,5) }, qr/\bOdd\b/; like exception { Quz->new(def=>4) }, qr/\bUnknown argument\b/i; - SKIP: { - skip "Won't work on old Perls", 2 if $] lt '5.008009'; - ok exception { my $x = $n->{new} }; - ok exception { my $x = $n->{DESTROY} }; - } + ok exception { my $x = $n->{new} }; + ok exception { my $x = $n->{DESTROY} }; } { my $o = h2o -meth, -new, { x=>111, y=>sub{222} }, qw/y/; @@ -448,8 +430,7 @@ sub checksym { is $o->test, ""; ok exists &Yet::Another::h2o; } -SKIP: { - skip "Won't work on really old Perls", 2 if $] lt '5.008'; +{ my @w = warns { my $x = h2o -clean=>1, -classify, {}; isa_ok $x, 'main'; @@ -466,19 +447,13 @@ SKIP: { $o->{bar} = 456; is $o->{bar}, 456; is_deeply [sort keys %$o], [qw/ bar foo /]; - SKIP: { - skip "Won't work on old Perls", 2 if $] lt '5.008009'; - ok exception { my $x = $o->{quz} }; - ok exception { $o->{quz} = 789 }; - } + ok exception { my $x = $o->{quz} }; + ok exception { $o->{quz} = 789 }; } { my $o = h2o -lock=>1, { foo=>123 }, qw/ bar /; - SKIP: { - skip "Won't work on old Perls", 2 if $] lt '5.008009'; - ok exception { my $x = $o->{quz} }; - ok exception { $o->{quz} = 789 }; - } + ok exception { my $x = $o->{quz} }; + ok exception { $o->{quz} = 789 }; } { my $o = h2o -lock=>0, { foo=>123 }, qw/ bar /; @@ -511,15 +486,8 @@ SKIP: { { h2o -class=>'Baz', -new, {}, qw/ abc /; my $n = Baz->new(abc=>123); - if ($] lt '5.008009') { - $n->{def} = 456; - is_deeply [sort keys %$n], [qw/ abc def /]; - pass 'dummy'; # so the number of tests still fits - } - else { - ok exception { $n->{def} = 456 }; - is_deeply [sort keys %$n], [qw/ abc /]; - } + ok exception { $n->{def} = 456 }; + is_deeply [sort keys %$n], [qw/ abc /]; } { h2o -class=>'Baz2', -new, -nolock, {}, qw/ abc /; @@ -529,8 +497,7 @@ SKIP: { } # -ro -SKIP: { - skip "Won't work on old Perls", 36 if $] lt '5.008009'; +{ my $o = h2o -ro, { foo=>123, bar=>undef }; is $o->foo, 123; is $o->bar, undef; @@ -695,20 +662,6 @@ my @redef_warns = warns { # There were spurious CPAN Testers failures here, see xt/redef.t for details ok !grep { /redefined/i } @redef_warns or diag explain \@redef_warns; ## no critic (ProhibitMixedBooleanOperators) -SKIP: { - skip "Tests only for old Perls", 4 if $] ge '5.008009'; - my @w = warns { - my $o1 = h2o {}; - $o1->{bar} = 456; - is_deeply [%$o1], [ bar=>456 ]; - my $o2 = h2o -ro, { foo=>123 }; - $o2->{foo} = 456; - ok exception { $o2->foo(789) }; - is_deeply [%$o2], [ foo=>456 ]; - }; - is grep({ /\btoo old\b/i } @w), 2; -} - { # -pass like blessed( h2o {} ), $PACKRE; like blessed( h2o -pass=>'undef', {} ), $PACKRE; @@ -767,7 +720,4 @@ ok exception { o2h(-arrays) }; ok exception { o2h(undef, undef) }; ok exception { o2h({x=>1},{y=>2}) }; -diag "If all tests pass, you can ignore the \"this Perl is too old\" warnings" - if $] lt '5.008009'; - done_testing; diff --git a/xt/author.t b/xt/author.t index 30a1581..a344770 100755 --- a/xt/author.t +++ b/xt/author.t @@ -70,7 +70,7 @@ pod_file_ok($_) for @PERLFILES; my @tasks; for my $file (@PERLFILES) { critic_ok($file); - minimum_version_ok($file, '5.006'); + minimum_version_ok($file, '5.008009'); open my $fh, '<', $file or die "$file: $!"; ## no critic (RequireCarping) while (<$fh>) { s/\A\s+|\s+\z//g;