From cf9daea6660c3dd579e93f1334d8b8c2aa980b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Tue, 9 Jan 2018 15:22:17 +0000 Subject: [PATCH 1/2] Support perl down to 5.8.1 This module is used by Devel::Cover::Report::Codecov, which would otherwise work on 5.8.1. --- Build.PL | 2 +- META.json | 2 +- cpanfile | 2 +- lib/Test/Mock/Time.pm | 16 +++++++++------- t/AnyEvent.t | 2 +- t/CORE.t | 2 +- t/EV.t | 2 +- t/Mojolicious-EV.t | 2 +- t/Mojolicious.t | 2 +- t/TimeHiRes.t | 2 +- 10 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Build.PL b/Build.PL index 232a8ab..3980b65 100644 --- a/Build.PL +++ b/Build.PL @@ -2,6 +2,6 @@ use strict; use warnings; -use 5.010001; +use 5.008001; use Module::Build::Tiny 0.034; Build_PL(); diff --git a/META.json b/META.json index 301c112..d7e4873 100644 --- a/META.json +++ b/META.json @@ -44,7 +44,7 @@ "Scalar::Util" : "0", "Test::MockModule" : "0", "bignum" : "0", - "perl" : "5.010001" + "perl" : "5.008001" } }, "test" : { diff --git a/cpanfile b/cpanfile index d72fffc..14b65f5 100644 --- a/cpanfile +++ b/cpanfile @@ -1,4 +1,4 @@ -requires 'perl', '5.010001'; +requires 'perl', '5.008001'; requires 'Export::Attrs'; requires 'List::Util', '1.33'; diff --git a/lib/Test/Mock/Time.pm b/lib/Test/Mock/Time.pm index 309fd14..84bcb87 100644 --- a/lib/Test/Mock/Time.pm +++ b/lib/Test/Mock/Time.pm @@ -1,5 +1,5 @@ package Test::Mock::Time; -use 5.010001; +use 5.008001; use warnings; use strict; use utf8; @@ -92,9 +92,10 @@ sub ff :Export(:DEFAULT) { goto &ff; } +{ +my $next_id = 0; sub _add_timer { my ($loop, $after, $repeat, $cb, $watcher) = @_; - state $next_id = 0; my $id = sprintf 'fake_%05d', $next_id++; push @Timers, { id => $id, @@ -110,6 +111,7 @@ sub _add_timer { } return $id; } +} sub _start_timer { my ($watcher) = @_; @@ -137,11 +139,11 @@ sub _mock_core_global { return int($Absolute + $Relative); }); $Module{'CORE::GLOBAL'}->mock(localtime => sub (;$) { - my $time = $_[0] // int($Absolute + $Relative); + my $time = defined $_[0] ? $_[0] : int($Absolute + $Relative); return CORE::localtime($time); }); $Module{'CORE::GLOBAL'}->mock(gmtime => sub (;$) { - my $time = $_[0] // int($Absolute + $Relative); + my $time = defined $_[0] ? $_[0] : int($Absolute + $Relative); return CORE::gmtime($time); }); $Module{'CORE::GLOBAL'}->mock(sleep => sub ($) { @@ -341,7 +343,7 @@ sub _mock_ev { ## no critic (ProhibitExcessComplexity) }); $Module{'EV::Timer'}->mock(set => sub { my ($w, $after, $repeat) = @_; - $repeat //= 0; + $repeat = 0 unless defined $repeat; my ($timer) = grep { $_->{watcher} && $_->{watcher} eq $w } @Timers, @Timers_ns; if ($timer) { $timer->{start} = $Relative; @@ -366,7 +368,7 @@ sub _mock_ev { ## no critic (ProhibitExcessComplexity) my ($active) = grep { $_->{watcher} && $_->{watcher} eq $w } @Timers; my ($inactive) = grep { $_->{watcher} && $_->{watcher} eq $w } @Timers_ns; if ($active) { - $active->{repeat} = sprintf '%.6f', $repeat // $active->{repeat}; + $active->{repeat} = sprintf '%.6f', defined $repeat ? $repeat : $active->{repeat}; if ($active->{repeat} > 0) { $active->{after} = $active->{repeat}; $active->{start} = $Relative; @@ -376,7 +378,7 @@ sub _mock_ev { ## no critic (ProhibitExcessComplexity) } } elsif ($inactive) { - $inactive->{repeat} = sprintf '%.6f', $repeat // $inactive->{repeat}; + $inactive->{repeat} = sprintf '%.6f', defined $repeat ? $repeat : $inactive->{repeat}; if ($inactive->{repeat} > 0) { $inactive->{after} = $inactive->{repeat}; $inactive->{start} = $Relative; diff --git a/t/AnyEvent.t b/t/AnyEvent.t index 84cee2f..a0266a9 100644 --- a/t/AnyEvent.t +++ b/t/AnyEvent.t @@ -1,4 +1,4 @@ -use 5.010001; +use 5.008001; use warnings; use strict; use utf8; diff --git a/t/CORE.t b/t/CORE.t index 9d3ed75..79b6d5d 100644 --- a/t/CORE.t +++ b/t/CORE.t @@ -1,4 +1,4 @@ -use 5.010001; +use 5.008001; use warnings; use strict; use utf8; diff --git a/t/EV.t b/t/EV.t index f55818b..8176150 100644 --- a/t/EV.t +++ b/t/EV.t @@ -1,4 +1,4 @@ -use 5.010001; +use 5.008001; use warnings; use strict; use utf8; diff --git a/t/Mojolicious-EV.t b/t/Mojolicious-EV.t index d35b7c9..41e9f87 100644 --- a/t/Mojolicious-EV.t +++ b/t/Mojolicious-EV.t @@ -1,4 +1,4 @@ -use 5.010001; +use 5.008001; use warnings; use strict; use utf8; diff --git a/t/Mojolicious.t b/t/Mojolicious.t index 3d2cf2b..dce4578 100644 --- a/t/Mojolicious.t +++ b/t/Mojolicious.t @@ -1,4 +1,4 @@ -use 5.010001; +use 5.008001; use warnings; use strict; use utf8; diff --git a/t/TimeHiRes.t b/t/TimeHiRes.t index 3723ba0..5a8ef9c 100644 --- a/t/TimeHiRes.t +++ b/t/TimeHiRes.t @@ -1,4 +1,4 @@ -use 5.010001; +use 5.008001; use warnings; use strict; use utf8; From d6dc31a79d2747a684863af02de0fa11e2021351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Tue, 9 Jan 2018 15:49:34 +0000 Subject: [PATCH 2/2] Test on 5.8 in Travis - Use the travis-perl helper, to install a working Devel::Cover on 5.8. - Allow Mojolicious install to fail, since it requires 5.10 --- .travis.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6f8bba4..167dcff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ sudo: false language: perl perl: + - "5.8" - "5.10" - "5.12" - "5.14" @@ -21,13 +22,10 @@ env: - EXTENDED_TESTING=1 - TEST_MYSQL_USER=root - TEST_MYSQL_PASS= + - COVERAGE="coveralls" before_install: - - cpanm -nq Devel::Cover::Report::Coveralls - - cpanm -nq EV Mojolicious AnyEvent + - eval $(curl https://travis-perl.github.io/init) --auto install: - - cpanm -nq --installdeps . -script: - - perl Build.PL && ./Build && cover -test -after_success: - - cover -report coveralls + - cpan-install --coverage --deps EV AnyEvent EV + - cpan-install Mojolicious || true # requires 5.10