Skip to content

Commit

Permalink
Time::R: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pink-mist committed Oct 24, 2016
1 parent 9c94b87 commit f9089e6
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions t/06-recurrence.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use strict;
use warnings;

use Test::More tests => 9;

use Time::C;
use Time::R;

my $y = Time::R->new(Time::C->new(2016,2,29), years => 1, end => Time::C->new(2020,3,1));

is ($y->next()->epoch, Time::C->new(2017,2,28)->epoch, "1st y->next correct");
is ($y->next()->epoch, Time::C->new(2018,2,28)->epoch, "2nd y->next correct");
is ($y->next()->epoch, Time::C->new(2019,2,28)->epoch, "3rd y->next correct");
is ($y->next()->epoch, Time::C->new(2020,2,29)->epoch, "4th y->next correct");
is ($y->next(), undef, "5th y->next correct");

my $m = Time::R->new(Time::C->new(2016,1,31), months => 1);

is ($m->next()->epoch, Time::C->new(2016,2,29)->epoch, "1st m->next correct");
is ($m->next()->epoch, Time::C->new(2016,3,31)->epoch, "2nd m->next correct");

$m->current = Time::C->new(2016,6,10);

is ($m->next()->epoch, Time::C->new(2016,6,30)->epoch, "3rd m->next correct");

$m->end = Time::C->new(2016,5,31);

is ($m->next(), undef, "4th m->next correct");

0 comments on commit f9089e6

Please sign in to comment.