File: construct.t

package info (click to toggle)
libdatetime-timezone-systemv-perl 0.010-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 132 kB
  • sloc: perl: 239; makefile: 2
file content (109 lines) | stat: -r--r--r-- 2,751 bytes parent folder | download | duplicates (4)
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
102
103
104
105
106
107
108
109
use warnings;
use strict;

use Test::More tests => 36;

require_ok "DateTime::TimeZone::SystemV";

my $tz;

$tz = DateTime::TimeZone::SystemV->new("EST5EDT");
ok $tz;
is $tz->name, "EST5EDT";

$tz = DateTime::TimeZone::SystemV->new(recipe => "EST5EDT");
ok $tz;
is $tz->name, "EST5EDT";

$tz = DateTime::TimeZone::SystemV->new(recipe => "EST5EDT", name => "foobar");
ok $tz;
is $tz->name, "foobar";

$tz = DateTime::TimeZone::SystemV->new(name => "foobar", recipe => "EST5EDT");
ok $tz;
is $tz->name, "foobar";

eval { DateTime::TimeZone::SystemV->new(); };
like $@, qr/\Arecipe not specified\b/;

eval { DateTime::TimeZone::SystemV->new(name => "foobar"); };
like $@, qr/\Arecipe not specified\b/;

eval { DateTime::TimeZone::SystemV->new(quux => "foobar"); };
like $@, qr/\Aunrecognised attribute\b/;

eval { DateTime::TimeZone::SystemV->new(name => "foobar", name => "quux"); };
like $@, qr/\Atimezone name specified redundantly\b/;

eval {
	DateTime::TimeZone::SystemV->new(recipe => "EST5EDT",
		recipe => "EST5EDT");
};
like $@, qr/\Arecipe specified redundantly\b/;

eval {
	DateTime::TimeZone::SystemV->new(system => "posix", system => "posix");
};
like $@, qr/\Asystem identifier specified redundantly\b/;

foreach(
	undef,
	[],
	*STDOUT,
	bless({}),
) {
	eval { DateTime::TimeZone::SystemV->new(name => $_) };
	like $@, qr/\Atimezone name must be a string\b/;
	eval { DateTime::TimeZone::SystemV->new(recipe => $_) };
	like $@, qr/\Arecipe must be a string\b/;
	eval { DateTime::TimeZone::SystemV->new(system => $_) };
	like $@, qr/\Asystem identifier must be a string\b/;
}

eval { DateTime::TimeZone::SystemV->new(system => "foobar"); };
like $@, qr/\Asystem identifier not recognised\b/;

eval { DateTime::TimeZone::SystemV->new(recipe => "EST"); };
like $@, qr/\Anot a valid SysV-style timezone recipe\b/;

eval { DateTime::TimeZone::SystemV->new(recipe => "EST", system => "posix"); };
like $@, qr/\Anot a valid SysV-style timezone recipe\b/;

eval {
	DateTime::TimeZone::SystemV->new(recipe => "EST", system => "tzfile3");
};
like $@, qr/\Anot a valid SysV-style timezone recipe\b/;

eval {
	DateTime::TimeZone::SystemV->new(recipe => "EST5EDT",
		system => "posix");
};
is $@, "";

eval {
	DateTime::TimeZone::SystemV->new(recipe => "EST5EDT",
		system => "tzfile3");
};
is $@, "";

eval {
	DateTime::TimeZone::SystemV->new(
		recipe => "EET-2EEST,M3.5.4/24,M9.3.6/145");
};
like $@, qr/\Anot a valid SysV-style timezone recipe\b/;

eval {
	DateTime::TimeZone::SystemV->new(
		recipe => "EET-2EEST,M3.5.4/24,M9.3.6/145",
		system => "posix");
};
like $@, qr/\Anot a valid SysV-style timezone recipe\b/;

eval {
	DateTime::TimeZone::SystemV->new(
		recipe => "EET-2EEST,M3.5.4/24,M9.3.6/145",
		system => "tzfile3");
};
is $@, "";

1;