Skip to content

Commit

Permalink
Increased minimum required Perl version to 5.8.9
Browse files Browse the repository at this point in the history
  • Loading branch information
haukex committed Sep 14, 2024
1 parent fcbaa7c commit 7882fba
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 99 deletions.
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 3 additions & 5 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
29 changes: 6 additions & 23 deletions lib/Util/H2O.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<Hash::Util> and its C<lock_ref_keys> 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<Hash::Util> and its C<lock_ref_keys> were not available.)
=item C<-nolock>
Expand All @@ -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<or> "undef" >>
Expand Down
86 changes: 18 additions & 68 deletions t/Util-H2O.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ L<http://perldoc.perl.org/perlartistic.html>.
=cut

use Test::More tests => 343;
use Test::More tests => 339;
use Scalar::Util qw/blessed/;
use Symbol qw/delete_package/;

Expand All @@ -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)

{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) };
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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/;
Expand Down Expand Up @@ -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/;
Expand Down Expand Up @@ -448,8 +430,7 @@ sub checksym {
is $o->test, "<def>";
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';
Expand All @@ -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 /;
Expand Down Expand Up @@ -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 /;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
2 changes: 1 addition & 1 deletion xt/author.t
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7882fba

Please sign in to comment.