CC: | lee.johnson [...] netbanx.com |
Subject: | Boxing Day is not identified in some cases |
The module appears to have a bug in recognizing Boxing Day in some
years, specifically those where Christmas day falls on a weekend. I have
attached a test case, output is as follows:
t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t .. 1/36
# Failed test '2010-12-28 is Boxing Day'
# at t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t line 24.
# got: undef
# expected: 'Boxing Day'
t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t .. 11/36
# Failed test '2011-12-26 is Christmas Day Bank Holiday'
# at t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t line 24.
# got: 'Boxing Day'
# expected: 'Christmas Day Bank Holiday'
# Failed test '2011-12-27 is Boxing Day'
# at t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t line 24.
# got: undef
# expected: 'Boxing Day'
# checking holidays until 2023
t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t .. 27/36
# Failed test '2016 has all holidays in order'
# at t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t line 77.
# Compared array length of $data
# got : array with 7 element(s)
# expect : array with 8 element(s)
# $VAR1 = [
# 'New Years Day',
# 'Good Friday',
# 'Easter Monday',
# 'Early May Bank Holiday',
# 'Spring Bank Holiday',
# 'Summer Bank Holiday',
# 'Boxing Day'
# ];
# Failed test '2021 has all holidays in order'
# at t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t line 77.
# Compared array length of $data
# got : array with 7 element(s)
# expect : array with 8 element(s)
# $VAR1 = [
# 'New Years Day',
# 'Good Friday',
# 'Easter Monday',
# 'Early May Bank Holiday',
# 'Spring Bank Holiday',
# 'Summer Bank Holiday',
# 'Christmas Day Bank Holiday'
# ];
# Failed test '2022 has all holidays in order'
# at t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t line 77.
# Compared array length of $data
# got : array with 7 element(s)
# expect : array with 8 element(s)
# $VAR1 = [
# 'New Years Day',
# 'Good Friday',
# 'Easter Monday',
# 'Early May Bank Holiday',
# 'Spring Bank Holiday',
# 'Summer Bank Holiday',
# 'Boxing Day'
# ];
# Looks like you failed 6 tests of 36.
t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t .. Dubious,
test returned 6 (wstat 1536, 0x600)
Failed 6/36 subtests
Test Summary Report
-------------------
t/base/Date::Holidays::EnglandWales/t/01_expected_dates.t (Wstat: 1536
Tests: 36 Failed: 6)
Failed tests: 9, 16-17, 30, 35-36
Non-zero exit status: 6
Files=1, Tests=36, 6 wallclock secs ( 0.04 usr 0.00 sys + 6.23 cusr
0.07 csys = 6.34 CPU)
Result: FAIL
Subject: | 01_expected_dates.t |
use strict;
use warnings;
use Test::More;
use Date::Simple;
use Data::Dumper;
use Test::Deep;
plan tests => 36;
use_ok( "Date::Holidays::EnglandWales" );
my %known_holidays = known_bank_holidays();
my $give_up = '2013-01-01';
my $date = Date::Simple->new( '2010-01-01' );
#
# check for known bank holidays
#
for ( ;; ) {
my $known_holiday = $known_holidays{$date} || undef;
if ( my $holiday = is_holiday( $date ) ) {
is( $holiday,$known_holiday,"$date is $known_holiday" );
}
elsif ( $known_holiday ) {
is( undef,$known_holiday,"$date is $known_holiday" );
}
$date = $date->next;
last if ( $date eq $give_up );
}
#
# check we have at least the expected number of bank holidays
# for the 10 years after the known bank holidays
#
my $final_year = $date->year + 10;
my %future_holidays;
diag( "checking holidays until $final_year" );
for ( ;; ) {
my $this_year = $date->year;
last if ( $this_year eq $final_year );
if ( my $holiday = is_holiday( $date ) ) {
push( @{ $future_holidays{$this_year} },$holiday );
}
$date = $date->next;
}
foreach my $year ( sort keys %future_holidays ) {
my $expected = [
"New Years Day",
"Good Friday",
'Easter Monday',
'Early May Bank Holiday',
'Spring Bank Holiday',
'Summer Bank Holiday',
'Christmas Day Bank Holiday',
'Boxing Day',
];
cmp_deeply(
$future_holidays{$year},
$expected,
"$year has all holidays in order",
) || do {
diag( Dumper $future_holidays{$year} );
};
}
sub known_bank_holidays {
#
# known bank hoildays, as per http://www.direct.gov.uk
#
return (
'2010-01-01' => "New Years Day",
'2011-01-03' => "New Years Day",
'2012-01-02' => "New Years Day",
'2010-04-02' => "Good Friday",
'2011-04-22' => "Good Friday",
'2012-04-06' => "Good Friday",
'2010-04-05' => 'Easter Monday',
'2011-04-25' => 'Easter Monday',
'2012-04-09' => 'Easter Monday',
'2010-05-03' => 'Early May Bank Holiday',
'2011-05-02' => 'Early May Bank Holiday',
'2012-05-07' => 'Early May Bank Holiday',
'2010-05-31' => 'Spring Bank Holiday',
'2011-05-30' => 'Spring Bank Holiday',
'2012-06-04' => 'Spring Bank Holiday',
'2012-06-05' => "Queen's Diamond Jubilee",
'2010-08-30' => 'Summer Bank Holiday',
'2011-08-29' => 'Summer Bank Holiday',
'2012-08-27' => 'Summer Bank Holiday',
'2010-12-27' => 'Christmas Day Bank Holiday',
'2011-12-26' => 'Christmas Day Bank Holiday',
'2012-12-25' => 'Christmas Day Bank Holiday',
'2010-12-28' => 'Boxing Day',
'2011-12-27' => 'Boxing Day',
'2012-12-26' => 'Boxing Day',
);
}