Skip to content

Commit

Permalink
Merge d6dc31a into 71246ef
Browse files Browse the repository at this point in the history
  • Loading branch information
ilmari committed Jan 9, 2018
2 parents 71246ef + d6dc31a commit 87bb875
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 23 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ sudo: false

language: perl
perl:
- "5.8"
- "5.10"
- "5.12"
- "5.14"
Expand All @@ -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
2 changes: 1 addition & 1 deletion Build.PL
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
use strict;
use warnings;

use 5.010001;
use 5.008001;
use Module::Build::Tiny 0.034;
Build_PL();
2 changes: 1 addition & 1 deletion META.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"Scalar::Util" : "0",
"Test::MockModule" : "0",
"bignum" : "0",
"perl" : "5.010001"
"perl" : "5.008001"
}
},
"test" : {
Expand Down
2 changes: 1 addition & 1 deletion cpanfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
requires 'perl', '5.010001';
requires 'perl', '5.008001';

requires 'Export::Attrs';
requires 'List::Util', '1.33';
Expand Down
16 changes: 9 additions & 7 deletions lib/Test/Mock/Time.pm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package Test::Mock::Time;
use 5.010001;
use 5.008001;
use warnings;
use strict;
use utf8;
Expand Down Expand Up @@ -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,
Expand All @@ -110,6 +111,7 @@ sub _add_timer {
}
return $id;
}
}

sub _start_timer {
my ($watcher) = @_;
Expand Down Expand Up @@ -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 ($) {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion t/AnyEvent.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use 5.010001;
use 5.008001;
use warnings;
use strict;
use utf8;
Expand Down
2 changes: 1 addition & 1 deletion t/CORE.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use 5.010001;
use 5.008001;
use warnings;
use strict;
use utf8;
Expand Down
2 changes: 1 addition & 1 deletion t/EV.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use 5.010001;
use 5.008001;
use warnings;
use strict;
use utf8;
Expand Down
2 changes: 1 addition & 1 deletion t/Mojolicious-EV.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use 5.010001;
use 5.008001;
use warnings;
use strict;
use utf8;
Expand Down
2 changes: 1 addition & 1 deletion t/Mojolicious.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use 5.010001;
use 5.008001;
use warnings;
use strict;
use utf8;
Expand Down
2 changes: 1 addition & 1 deletion t/TimeHiRes.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use 5.010001;
use 5.008001;
use warnings;
use strict;
use utf8;
Expand Down

0 comments on commit 87bb875

Please sign in to comment.