File: 43new-params.t

package info (click to toggle)
libdatetime-perl 2%3A1.50-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,504 kB
  • sloc: perl: 2,964; makefile: 3
file content (101 lines) | stat: -rw-r--r-- 2,206 bytes parent folder | download | duplicates (3)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
use strict;
use warnings;

use Test::Fatal;
use Test::More;

use DateTime;

like(
    exception { DateTime->new( year => 10.5 ) },
    qr/Validation failed for type named Year/,
    'year must be an integer'
);
like(
    exception { DateTime->new( year => -10.5 ) },
    qr/Validation failed for type named Year/,
    'year must be an integer'
);

like(
    exception { DateTime->new( year => 10, month => 2.5 ) },
    qr/Validation failed for type named Month/,
    'month must be an integer'
);

like(
    exception { DateTime->new( year => 10, month => 2, day => 12.4 ) },
    qr/Validation failed for type named DayOfMonth/,
    'day must be an integer'
);

like(
    exception {
        DateTime->new( year => 10, month => 2, day => 12, hour => 4.1 );
    },
    qr/Validation failed for type named Hour/,
    'hour must be an integer'
);

like(
    exception {
        DateTime->new(
            year   => 10,
            month  => 2,
            day    => 12,
            hour   => 4,
            minute => 12.2
        );
    },
    qr/Validation failed for type named Minute/,
    'minute must be an integer'
);

like(
    exception {
        DateTime->new(
            year   => 10,
            month  => 2,
            day    => 12,
            hour   => 4,
            minute => 12,
            second => 51.8
        );
    },
    qr/Validation failed for type named Second/,
    'second must be an integer'
);

like(
    exception {
        DateTime->new(
            year       => 10,
            month      => 2,
            day        => 12,
            hour       => 4,
            minute     => 12,
            second     => 51,
            nanosecond => 124512.12412
        );
    },
    qr/Validation failed for type named Nanosecond/,
    'nanosecond must be an integer'
);

like(
    exception {
        DateTime->new( year => 10, month => 2, day => 12 )->today;
    },
    qr/called with reference/,
    'today must be called as a class method, not an object method'
);

like(
    exception {
        DateTime->new( year => 10, month => 2, day => 12 )->now;
    },
    qr/called with reference/,
    'now must be called as a class method, not an object method'
);

done_testing();