blib/lib/Date/Holidays/PF.pm

filter: Statementstmt 86.8% 53 / 61 Branchbran 86.6% 26 / 30 Conditioncond 66.6% 30 / 45 MC/DCmcdc 46.6% 14 / 30 Subroutinesub 84.6% 11 / 13 Podpod 83.3% 5 / 6 totaltotal 75.1% 139 / 185 CC 31 SCAR 34.5
CC
31
Cov
80%
is_pf_holiday
43.4
get_vendredisaint
2.0
get_lundipaques
2.0
CRAP 31.6
↑ Summary
1 package Date::Holidays::PF;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Time::Local;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Date::Easter;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 our @ISA = qw(Exporter);
9 1 our @EXPORT = qw(is_pf_holiday get_easter get_ascension get_pentecost get_vendredisaint get_lundipaques);
10  
11 1 our $VERSION = '0.03';
12 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 33 ▶sub get_easter {
Subroutine get_easter: called CC=1 SCAR=0.0
Pod documented
15 33 my ($year) = @_;
16 33 return Date::Easter::easter($year);
17 }
18  
19 1 ▶sub get_ascension {
Subroutine get_ascension: called CC=1 SCAR=0.0
Pod documented
20 1 my ($year) = @_;
21 1 return _compute_date_from_easter($year, 39);
22 }
23  
24 1 ▶sub get_pentecost {
Subroutine get_pentecost: called CC=1 SCAR=0.0
Pod documented
25 1 my ($year) = @_;
26 1 return _compute_date_from_easter($year, 50);
27 }
28  
29 0 ▶sub get_vendredisaint {
Subroutine get_vendredisaint: not called CC=1 SCAR=6.9
Pod documented
30 0 my ($year) = @_;
31 0 return _compute_date_from_easter($year, -2);
32 }
33  
34 0 ▶sub get_lundipaques {
Subroutine get_lundipaques: not called CC=1 SCAR=6.9
Pod undocumented
35 0 my ($year) = @_;
36 0 return _compute_date_from_easter($year, 1);
37 }
38  
39 26 ▶sub _compute_date_from_easter {
Subroutine _compute_date_from_easter: called CC=1 SCAR=0.0
40 26 my ($year, $delta) = @_;
41  
42 26 my ($easter_month, $easter_day) = get_easter($year);
43 26 my $easter_date = Time::Local::timelocal(0, 0, 1, $easter_day, $easter_month - 1, $year - 1900);
44 26 my ($date_month, $date_day) = (localtime($easter_date + $delta * 86400))[4, 3];
45 26 $date_month++;
46  
47 26 return ($date_month, $date_day);
48 }
49  
50 14 ▶sub is_pf_holiday {
Subroutine is_pf_holiday: called CC=31 SCAR=37.7
Pod documented
51 14 my ($year, $month, $day) = @_;
52  
53 14 ▶ if ($day == 1 and $month == 1) { return "Nouvel an"; }
Branch: 10 branches
BranchTrueFalseTotal
if ($day == 1 and $month == 1) { } 1 13 14
elsif ($day == 5 and $month == 3) { } 0 13 13
elsif ($day == 1 and $month == 5) { } 1 12 13
elsif ($day == 8 and $month == 5) { } 1 11 12
elsif ($day == 29 and $month == 6) { } 0 11 11
elsif ($day == 14 and $month == 7) { } 1 10 11
elsif ($day == 15 and $month == 8) { } 1 9 10
elsif ($day == 1 and $month == 11) { } 1 8 9
elsif ($day == 11 and $month == 11) { } 1 7 8
elsif ($day == 25 and $month == 12) { } 1 6 7
Condition100%3/3
$day == 1 and $month == 1
!ll&&!rl&&r
1121
MC/DC100%2/2
$day == 1 and $month == 1
$day == 1 $month == 1
Truth table100%3/3
A and B
A= $day == 1B= $month == 1
ABresult
0X0
100
111
54 0 ▶ elsif ($day == 5 and $month == 3) { return "Arrivé de l'évangile"; }
Condition33%1/3
$day == 5 and $month == 3
!ll&&!rl&&r
1300
MC/DC0%0/2
$day == 5 and $month == 3
$day == 5 $month == 3
Truth table33%1/3
A and B
A= $day == 5B= $month == 3
ABresult
0X0
100
111
55 1 ▶ elsif ($day == 1 and $month == 5) { return "Fête du travail"; }
Condition100%3/3
$day == 1 and $month == 5
!ll&&!rl&&r
1111
MC/DC100%2/2
$day == 1 and $month == 5
$day == 1 $month == 5
Truth table100%3/3
A and B
A= $day == 1B= $month == 5
ABresult
0X0
100
111
56 1 ▶ elsif ($day == 8 and $month == 5) { return "Armistice 39-45"; }
Condition66%2/3
$day == 8 and $month == 5
!ll&&!rl&&r
1101
MC/DC50%1/2
$day == 8 and $month == 5
$day == 8 $month == 5
Truth table66%2/3
A and B
A= $day == 8B= $month == 5
ABresult
0X0
100
111
57 0 ▶ elsif ($day == 29 and $month == 6) { return "Fête de l'autonomie"; }
Condition33%1/3
$day == 29 and $month == 6
!ll&&!rl&&r
1100
MC/DC0%0/2
$day == 29 and $month == 6
$day == 29 $month == 6
Truth table33%1/3
A and B
A= $day == 29B= $month == 6
ABresult
0X0
100
111
58 1 ▶ elsif ($day == 14 and $month == 7) { return "Fête nationale"; }
Condition66%2/3
$day == 14 and $month == 7
!ll&&!rl&&r
1001
MC/DC50%1/2
$day == 14 and $month == 7
$day == 14 $month == 7
Truth table66%2/3
A and B
A= $day == 14B= $month == 7
ABresult
0X0
100
111
59 1 ▶ elsif ($day == 15 and $month == 8) { return "Assomption"; }
Condition66%2/3
$day == 15 and $month == 8
!ll&&!rl&&r
901
MC/DC50%1/2
$day == 15 and $month == 8
$day == 15 $month == 8
Truth table66%2/3
A and B
A= $day == 15B= $month == 8
ABresult
0X0
100
111
60 1 ▶ elsif ($day == 1 and $month == 11) { return "Toussaint"; }
Condition66%2/3
$day == 1 and $month == 11
!ll&&!rl&&r
801
MC/DC50%1/2
$day == 1 and $month == 11
$day == 1 $month == 11
Truth table66%2/3
A and B
A= $day == 1B= $month == 11
ABresult
0X0
100
111
61 1 ▶ elsif ($day == 11 and $month == 11) { return "Armistice 14-18"; }
Condition100%3/3
$day == 11 and $month == 11
!ll&&!rl&&r
611
MC/DC100%2/2
$day == 11 and $month == 11
$day == 11 $month == 11
Truth table100%3/3
A and B
A= $day == 11B= $month == 11
ABresult
0X0
100
111
62 1 ▶ elsif ($day == 25 and $month == 12) { return "Noël"; }
Condition66%2/3
$day == 25 and $month == 12
!ll&&!rl&&r
601
MC/DC50%1/2
$day == 25 and $month == 12
$day == 25 $month == 12
Truth table66%2/3
A and B
A= $day == 25B= $month == 12
ABresult
0X0
100
111
63 else {
64 6 my ($easter_month, $easter_day) = get_easter($year);
65 6 my ($vendredisaint_month, $vendredisaint_day) = _compute_date_from_easter($year, -2);
66 6 my ($lundipaques_month, $lundipaques_day) = _compute_date_from_easter($year, 1);
67 6 my ($ascension_month, $ascension_day) = _compute_date_from_easter($year, 39);
68 6 my ($pentecost_month, $pentecost_day) = _compute_date_from_easter($year, 50);
69  
70 0 ▶ if ($day == $easter_day and $month == $easter_month) { return "Pâques"; }
Branch: 5 branches
BranchTrueFalseTotal
if ($day == $easter_day and $month == $easter_month) { } 0 6 6
elsif ($day == $lundipaques_day and $month == $lundipaques_month) { } 1 5 6
elsif ($day == $vendredisaint_day and $month == $vendredisaint_month) { } 0 5 5
elsif ($day == $ascension_day and $month == $ascension_month) { } 1 4 5
elsif ($day == $pentecost_day and $month == $pentecost_month) { } 1 6 7
Condition66%2/3
$day == $easter_day and $month == $easter_month
!ll&&!rl&&r
510
MC/DC0%0/2
$day == $easter_day and $month == $easter_month
$day == $easter_day $month == $easter_month
Truth table66%2/3
A and B
A= $day == $easter_dayB= $month == $easter_month
ABresult
0X0
100
111
71 1 ▶ elsif ($day == $lundipaques_day and $month == $lundipaques_month) { return "Lundi de pâques"; }
Condition66%2/3
$day == $lundipaques_day and $month == $lundipaques_month
!ll&&!rl&&r
501
MC/DC50%1/2
$day == $lundipaques_day and $month == $lundipaques_month
$day == $lundipaques_day $month == $lundipaques_month
Truth table66%2/3
A and B
A= $day == $lundipaques_dayB= $month == $lundipaques_month
ABresult
0X0
100
111
72 0 ▶ elsif ($day == $vendredisaint_day and $month == $vendredisaint_month) { return "Vendredi saint"; }
Condition33%1/3
$day == $vendredisaint_day and $month == $vendredisaint_month
!ll&&!rl&&r
500
MC/DC0%0/2
$day == $vendredisaint_day and $month == $vendredisaint_month
$day == $vendredisaint_day $month == $vendredisaint_month
Truth table33%1/3
A and B
A= $day == $vendredisaint_dayB= $month == $vendredisaint_month
ABresult
0X0
100
111
73 1 ▶ elsif ($day == $ascension_day and $month == $ascension_month) { return "Ascension"; }
Condition66%2/3
$day == $ascension_day and $month == $ascension_month
!ll&&!rl&&r
401
MC/DC50%1/2
$day == $ascension_day and $month == $ascension_month
$day == $ascension_day $month == $ascension_month
Truth table66%2/3
A and B
A= $day == $ascension_dayB= $month == $ascension_month
ABresult
0X0
100
111
74 1 ▶ elsif ($day == $pentecost_day and $month == $pentecost_month) { return "Lundi de Pentecôte"; }
Condition66%2/3
$day == $pentecost_day and $month == $pentecost_month
!ll&&!rl&&r
301
MC/DC50%1/2
$day == $pentecost_day and $month == $pentecost_month
$day == $pentecost_day $month == $pentecost_month
Truth table66%2/3
A and B
A= $day == $pentecost_dayB= $month == $pentecost_month
ABresult
0X0
100
111
75 }
76 }
77  
78 1 1;
79  
80 __END__
↑ Summary