Skip to content

Commit 7882fba

Browse files
committed
Increased minimum required Perl version to 5.8.9
1 parent fcbaa7c commit 7882fba

File tree

6 files changed

+30
-99
lines changed

6 files changed

+30
-99
lines changed

Changes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Revision history for Perl extension Util::H2O.
22

33
0.26 not yet released
4-
- ...
4+
- Increased minimum required Perl version to 5.8.9
55

66
0.24 Wed, Dec 13 2023 commit 10a8b75ad51a195fc8c8a7a5e8633bec4bf6eb8b
77
- fix a bug where o2h would die on scalars that looked like options

Makefile.PL

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ WriteMakefile(
66
LICENSE => 'perl_5',
77
VERSION_FROM => 'lib/Util/H2O.pm',
88
ABSTRACT_FROM => 'lib/Util/H2O.pm',
9-
MIN_PERL_VERSION => '5.6.0',
9+
MIN_PERL_VERSION => '5.8.9',
1010
META_MERGE => {
1111
'meta-spec' => { version => 2 },
1212
provides => {
1313
'Util::H2O' => {
1414
file => 'lib/Util/H2O.pm',
15-
version => '0.24',
15+
version => '0.26',
1616
},
1717
},
1818
resources => {
@@ -34,9 +34,7 @@ WriteMakefile(
3434
'Carp' => 0,
3535
'Exporter' => '5.58',
3636
'Symbol' => 0,
37-
( $] ge '5.008009' ? (
38-
'Hash::Util' => '0.06',
39-
):()),
37+
'Hash::Util' => '0.06',
4038
},
4139
TEST_REQUIRES => {
4240
'Test::More' => '1.302096',

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ instead of `make`.
3030
Dependencies
3131
------------
3232

33-
Requirements: Perl v5.6 or higher (a more current version is *strongly*
33+
Requirements: Perl v5.8.9 or higher (a more current version is *strongly*
3434
recommended) and several of its core modules; users of older Perls may need
3535
to upgrade some core modules.
3636

lib/Util/H2O.pm

+6-23
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
package Util::H2O;
33
use warnings;
44
use strict;
5-
use Exporter 'import';
65
use Carp;
6+
use Exporter 'import';
77
use Symbol qw/delete_package/;
8+
use Hash::Util qw/ lock_ref_keys lock_hashref /;
89

910
=head1 Name
1011
@@ -46,21 +47,6 @@ our $VERSION = '0.26';
4647
our @EXPORT = qw/ h2o /; ## no critic (ProhibitAutomaticExportation)
4748
our @EXPORT_OK = qw/ o2h /;
4849

49-
BEGIN {
50-
# lock_ref_keys wasn't available until Hash::Util 0.06 / Perl v5.8.9
51-
# (note the following will probably also fail on the Perl v5.9 dev releases)
52-
# uncoverable branch false
53-
# uncoverable condition false
54-
if ( $] ge '5.008009' ) {
55-
require Hash::Util;
56-
Hash::Util->import(qw/ lock_ref_keys lock_hashref /) }
57-
else {
58-
*lock_ref_keys = *lock_hashref = sub {
59-
carp "this Perl is too old to lock the hash"; # uncoverable statement
60-
}; # uncoverable statement
61-
}
62-
}
63-
6450
=head1 Description
6551
6652
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
223209
C<-new> option are also locked. Versions of this module before
224210
v0.12 did not lock the keysets of new objects.
225211
226-
Note that on really old Perls, that is, before Perl v5.8.9,
227-
L<Hash::Util> and its C<lock_ref_keys> are not available, so the hash
228-
is never locked on those versions of Perl. Versions of this module
229-
before v0.06 did not lock the keyset.
212+
Versions of this module before v0.06 did not lock the keyset.
230213
Versions of this module as of v0.12 issue a warning on old Perls.
214+
(Versions of this module before v0.26 were compatible with Perls older than v5.8.9,
215+
where L<Hash::Util> and its C<lock_ref_keys> were not available.)
231216
232217
=item C<-nolock>
233218
@@ -244,9 +229,7 @@ also use the C<-new> option - the additional keys will then only be useful as
244229
arguments to the constructor. This option can't be used with C<-nolock> or
245230
C<< -lock=>0 >>.
246231
247-
This option was added in v0.12. Using this option will not work and cause a
248-
warning when used on really old Perls (before v5.8.9), because this
249-
functionality was not yet available there.
232+
This option was added in v0.12.
250233
251234
=item C<< -pass => "ref" I<or> "undef" >>
252235

t/Util-H2O.t

+18-68
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ L<http://perldoc.perl.org/perlartistic.html>.
2020
2121
=cut
2222

23-
use Test::More tests => 343;
23+
use Test::More tests => 339;
2424
use Scalar::Util qw/blessed/;
2525
use Symbol qw/delete_package/;
2626

@@ -33,9 +33,6 @@ diag "This is Perl $] at $^X on $^O";
3333
BEGIN { use_ok 'Util::H2O' }
3434
is $Util::H2O::VERSION, '0.26';
3535

36-
diag "If all tests pass, you can ignore the \"this Perl is too old\" warnings"
37-
if $] lt '5.008009';
38-
3936
my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars)
4037

4138
{
@@ -86,11 +83,8 @@ my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars)
8683
}
8784
{
8885
my $o = h2o -recurse, { foo => { bar => "quz" } };
89-
SKIP: {
90-
skip "Won't work on old Perls", 2 if $] lt '5.008009';
91-
ok exception { $o->{abc} = 123 };
92-
ok exception { $o->foo->{def} = 456 };
93-
}
86+
ok exception { $o->{abc} = 123 };
87+
ok exception { $o->foo->{def} = 456 };
9488
my $o2 = h2o -recurse, -nolock, { foo => { bar => "quz" } };
9589
$o2->{abc} = 123;
9690
$o2->foo->{def} = 456;
@@ -153,11 +147,8 @@ my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars)
153147
# -arrays + -lock + -ro
154148
{
155149
my $o = h2o -arrays, -lock=>1, -ro, { abc => [ { def => 'ghi' } ] };
156-
SKIP: {
157-
skip "Won't work on old Perls", 2 if $] lt '5.008009';
158-
ok exception { my $x = $o->{zzz} };
159-
ok exception { my $y = $o->{abc}[0]{def}{yyy} };
160-
}
150+
ok exception { my $x = $o->{zzz} };
151+
ok exception { my $y = $o->{abc}[0]{def}{yyy} };
161152
is $o->abc->[0]->def, 'ghi';
162153
ok exception { $o->abc(123) };
163154
ok exception { $o->abc->[0]->def(123) };
@@ -205,11 +196,8 @@ my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars)
205196
# o2h + -lock + -ro
206197
{
207198
my $o = h2o -recurse, -lock=>1, -ro, { abc => { def => { ghi => 555 } } };
208-
SKIP: {
209-
skip "Won't work on old Perls", 2 if $] lt '5.008009';
210-
ok exception { my $x = $o->{zzz} };
211-
ok exception { my $y = $o->{abc}{def}{yyy} };
212-
}
199+
ok exception { my $x = $o->{zzz} };
200+
ok exception { my $y = $o->{abc}{def}{yyy} };
213201
my $h = o2h $o;
214202
is ref $h, 'HASH';
215203
is ref $h->{abc}{def}, 'HASH';
@@ -268,10 +256,7 @@ my $PACKRE = $Util::H2O::_PACKAGE_REGEX; ## no critic (ProtectPrivateVars)
268256
is $o->y, 222;
269257
is_deeply [sort keys %$o], [qw/ x /];
270258
is $o->{x}, 111;
271-
SKIP: {
272-
skip "Won't work on old Perls", 1 if $] lt '5.008009';
273-
ok exception { my $x = $o->{y} };
274-
}
259+
ok exception { my $x = $o->{y} };
275260
}
276261
{
277262
my $o = h2o -meth, { x=>111, y=>sub{222} }, qw/y/;
@@ -402,11 +387,8 @@ sub checksym {
402387
is $n3->abc, 444;
403388
like exception { Quz->new(abc=>4,5) }, qr/\bOdd\b/;
404389
like exception { Quz->new(def=>4) }, qr/\bUnknown argument\b/i;
405-
SKIP: {
406-
skip "Won't work on old Perls", 2 if $] lt '5.008009';
407-
ok exception { my $x = $n->{new} };
408-
ok exception { my $x = $n->{DESTROY} };
409-
}
390+
ok exception { my $x = $n->{new} };
391+
ok exception { my $x = $n->{DESTROY} };
410392
}
411393
{
412394
my $o = h2o -meth, -new, { x=>111, y=>sub{222} }, qw/y/;
@@ -448,8 +430,7 @@ sub checksym {
448430
is $o->test, "<def>";
449431
ok exists &Yet::Another::h2o;
450432
}
451-
SKIP: {
452-
skip "Won't work on really old Perls", 2 if $] lt '5.008';
433+
{
453434
my @w = warns {
454435
my $x = h2o -clean=>1, -classify, {};
455436
isa_ok $x, 'main';
@@ -466,19 +447,13 @@ SKIP: {
466447
$o->{bar} = 456;
467448
is $o->{bar}, 456;
468449
is_deeply [sort keys %$o], [qw/ bar foo /];
469-
SKIP: {
470-
skip "Won't work on old Perls", 2 if $] lt '5.008009';
471-
ok exception { my $x = $o->{quz} };
472-
ok exception { $o->{quz} = 789 };
473-
}
450+
ok exception { my $x = $o->{quz} };
451+
ok exception { $o->{quz} = 789 };
474452
}
475453
{
476454
my $o = h2o -lock=>1, { foo=>123 }, qw/ bar /;
477-
SKIP: {
478-
skip "Won't work on old Perls", 2 if $] lt '5.008009';
479-
ok exception { my $x = $o->{quz} };
480-
ok exception { $o->{quz} = 789 };
481-
}
455+
ok exception { my $x = $o->{quz} };
456+
ok exception { $o->{quz} = 789 };
482457
}
483458
{
484459
my $o = h2o -lock=>0, { foo=>123 }, qw/ bar /;
@@ -511,15 +486,8 @@ SKIP: {
511486
{
512487
h2o -class=>'Baz', -new, {}, qw/ abc /;
513488
my $n = Baz->new(abc=>123);
514-
if ($] lt '5.008009') {
515-
$n->{def} = 456;
516-
is_deeply [sort keys %$n], [qw/ abc def /];
517-
pass 'dummy'; # so the number of tests still fits
518-
}
519-
else {
520-
ok exception { $n->{def} = 456 };
521-
is_deeply [sort keys %$n], [qw/ abc /];
522-
}
489+
ok exception { $n->{def} = 456 };
490+
is_deeply [sort keys %$n], [qw/ abc /];
523491
}
524492
{
525493
h2o -class=>'Baz2', -new, -nolock, {}, qw/ abc /;
@@ -529,8 +497,7 @@ SKIP: {
529497
}
530498

531499
# -ro
532-
SKIP: {
533-
skip "Won't work on old Perls", 36 if $] lt '5.008009';
500+
{
534501
my $o = h2o -ro, { foo=>123, bar=>undef };
535502
is $o->foo, 123;
536503
is $o->bar, undef;
@@ -695,20 +662,6 @@ my @redef_warns = warns {
695662
# There were spurious CPAN Testers failures here, see xt/redef.t for details
696663
ok !grep { /redefined/i } @redef_warns or diag explain \@redef_warns; ## no critic (ProhibitMixedBooleanOperators)
697664

698-
SKIP: {
699-
skip "Tests only for old Perls", 4 if $] ge '5.008009';
700-
my @w = warns {
701-
my $o1 = h2o {};
702-
$o1->{bar} = 456;
703-
is_deeply [%$o1], [ bar=>456 ];
704-
my $o2 = h2o -ro, { foo=>123 };
705-
$o2->{foo} = 456;
706-
ok exception { $o2->foo(789) };
707-
is_deeply [%$o2], [ foo=>456 ];
708-
};
709-
is grep({ /\btoo old\b/i } @w), 2;
710-
}
711-
712665
{ # -pass
713666
like blessed( h2o {} ), $PACKRE;
714667
like blessed( h2o -pass=>'undef', {} ), $PACKRE;
@@ -767,7 +720,4 @@ ok exception { o2h(-arrays) };
767720
ok exception { o2h(undef, undef) };
768721
ok exception { o2h({x=>1},{y=>2}) };
769722

770-
diag "If all tests pass, you can ignore the \"this Perl is too old\" warnings"
771-
if $] lt '5.008009';
772-
773723
done_testing;

xt/author.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pod_file_ok($_) for @PERLFILES;
7070
my @tasks;
7171
for my $file (@PERLFILES) {
7272
critic_ok($file);
73-
minimum_version_ok($file, '5.006');
73+
minimum_version_ok($file, '5.008009');
7474
open my $fh, '<', $file or die "$file: $!"; ## no critic (RequireCarping)
7575
while (<$fh>) {
7676
s/\A\s+|\s+\z//g;

0 commit comments

Comments
 (0)