File: 10deprecated.t

package info (click to toggle)
libdatetime-locale-perl 1%3A0.45-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze, wheezy
  • size: 7,816 kB
  • ctags: 8,274
  • sloc: xml: 22,344; perl: 1,565; makefile: 9
file content (40 lines) | stat: -rw-r--r-- 756 bytes parent folder | download | duplicates (2)
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
use strict;
use warnings;

use Test::More;

eval "use Test::Output";
if ($@) {
    plan skip_all => 'These tests require Test::Output.';
}

plan tests => 2;

use DateTime::Locale;

my $loc = DateTime::Locale->load('en');

my @months;
my $sub = sub {
    for my $m ( 1 .. 12 ) {
        my $dt = bless { m => $m }, 'FakeDateTime';
        push @months, $loc->month_abbreviation($dt);
    }
};

stderr_like(
    $sub,
    qr/month_abbreviation method in DateTime::Locale::Base has been deprecated/,
    'got a deprecation warning for month_abbreviation'
);
is_deeply(
    \@months, [qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec )],
    'month_abbreviation returns the right data'
);

{

    package FakeDateTime;

    sub month_0 { $_[0]->{m} - 1 }
}