File: 15-regression.t

package info (click to toggle)
libdatetime-format-natural-perl 1.21-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 616 kB
  • sloc: perl: 9,587; makefile: 2
file content (38 lines) | stat: -rwxr-xr-x 956 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
#!/usr/bin/perl

use strict;
use warnings;

use Test::MockTime::HiRes qw(set_fixed_time);
use DateTime::Format::Natural;
use Test::More tests => 4;

{
    local $@;
    eval {
        set_fixed_time('31.03.2009 04:32:22', '%d.%m.%Y %H:%M:%S');
        DateTime::Format::Natural->new->parse_datetime('april 3');
    };
    ok(!$@, 'units set at once');
}

{
    # rt #49326
    set_fixed_time('31.08.2009', '%d.%m.%Y');
    my $parser = DateTime::Format::Natural->new;
    $parser->parse_datetime('30/11/2009');
    ok($parser->success, '_check_date() sets at once');
}

{
    set_fixed_time('29.03.2011', '%d.%m.%Y');
    my $parser = DateTime::Format::Natural->new;
    $parser->parse_datetime('february');
    ok($parser->success, 'month set with current overlapping day');
}

{
    my $parser = DateTime::Format::Natural->new(daytime => { morning => 0 });
    my $dt = $parser->parse_datetime('morning');
    is($dt->hour, 0, 'daytime with 0 value');
}