1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
use strict;
use warnings;
use Test::More;
use Test::Warnings 0.005 ':all';
use DateTime;
my $year_5001_epoch = 95649120000;
## no critic (TestingAndDebugging::ProhibitNoWarnings)
SKIP:
{
my $year = ( gmtime($year_5001_epoch) )[5];
skip 'These tests require a 64-bit Perl', 2
unless defined $year && $year == 3101;
{
like(
warning {
DateTime->from_epoch(
epoch => $year_5001_epoch,
time_zone => 'Asia/Taipei',
);
},
qr{\QYou are creating a DateTime object with a far future year (5001) and a time zone (Asia/Taipei).},
'got a warning when calling ->from_epoch with a far future epoch and a time_zone'
);
}
{
no warnings 'DateTime';
is_deeply(
warning {
DateTime->from_epoch(
epoch => $year_5001_epoch,
time_zone => 'Asia/Taipei',
);
},
[],
'no warning when calling ->from_epoch with a far future epoch and a time_zone with DateTime warnings category suppressed'
);
}
}
{
like(
warning {
DateTime->new(
year => 5001,
time_zone => 'Asia/Taipei',
);
},
qr{\QYou are creating a DateTime object with a far future year (5001) and a time zone (Asia/Taipei).},
'got a warning when calling ->new with a far future year and a time_zone'
);
}
{
no warnings 'DateTime';
is_deeply(
warning {
DateTime->new(
year => 5001,
time_zone => 'Asia/Taipei',
);
},
[],
'no warning when calling ->new with a far future epoch and a time_zone with DateTime warnings category suppressed'
);
}
{
no warnings;
is_deeply(
warning {
DateTime->new(
year => 5001,
time_zone => 'Asia/Taipei',
);
},
[],
'no warning when calling ->new with a far future epoch and a time_zone with all warnings suppressed'
);
}
done_testing();
|