1use strict;
2use warnings;
3
4use Test::More tests => 14;
5
6use DateTime::Locale;
7
8{
9
10    package DateTime::Locale::en_GB_RIDAS;
11
12    use base qw(DateTime::Locale::root);
13}
14
15{
16
17    package DateTime::Locale::en_FOO_BAR;
18
19    use base qw(DateTime::Locale::root);
20}
21
22{
23
24    package DateTime::Locale::en_BAZ_BUZ;
25
26    use base qw(DateTime::Locale::root);
27}
28
29{
30
31    package DateTime::Locale::en_QUUX_QUAX;
32
33    use base qw(DateTime::Locale::root);
34}
35
36{
37
38    package DateTime::Locale::fr_FR_BZH2;
39    @DateTime::Locale::fr_FR_BZH2::ISA = qw(DateTime::Locale::root);
40    sub short_date_format {'test test2'}
41}
42{
43
44    package Other::Locale::fr_FR_BZH;
45    @Other::Locale::fr_FR_BZH::ISA = qw(DateTime::Locale::root);
46    sub short_date_format {'test test2'}
47}
48
49DateTime::Locale->register(
50    id           => 'en_GB_RIDAS',
51    en_language  => 'English',
52    en_territory => 'United Kingdom',
53    en_variant   => 'Ridas Custom Locale',
54);
55
56{
57    my $l = DateTime::Locale->load('en_GB_RIDAS');
58    ok( $l, 'was able to load en_GB_RIDAS' );
59    is( $l->variant, 'Ridas Custom Locale', 'variant is set properly' );
60}
61
62DateTime::Locale->register(
63    {
64        id           => 'en_FOO_BAR',
65        en_language  => 'English',
66        en_territory => 'United Kingdom',
67        en_variant   => 'Foo Bar',
68    }, {
69        id           => 'en_BAZ_BUZ',
70        en_language  => 'English',
71        en_territory => 'United Kingdom',
72        en_variant   => 'Baz Buz',
73    },
74);
75
76{
77    my $l = DateTime::Locale->load('en_FOO_BAR');
78    ok( $l, 'was able to load en_FOO_BAR' );
79    is( $l->variant, 'Foo Bar', 'variant is set properly' );
80
81    $l = DateTime::Locale->load('en_BAZ_BUZ');
82    ok( $l, 'was able to load en_BAZ_BUZ' );
83    is( $l->variant, 'Baz Buz', 'variant is set properly' );
84}
85
86# backwards compatibility
87DateTime::Locale->register(
88    {
89        id           => 'en_QUUX_QUAX',
90        en_language  => 'English',
91        en_territory => 'United Kingdom',
92        en_variant   => 'Wacko',
93    },
94);
95
96{
97    my $l = DateTime::Locale->load('en_QUUX_QUAX');
98    ok( $l, 'was able to load en_QUUX_QUAX' );
99    is( $l->variant, 'Wacko', 'variant is set properly' );
100}
101
102# there was a bug with register if the class passed in had an explicit
103# DateTime:: namespace
104{
105    DateTime::Locale->register(
106        id           => 'fr_FR_BZH2',
107        en_language  => 'French2',
108        en_territory => 'French2',
109        en_variant   => 'Britanny2',
110        class        => 'DateTime::Locale::fr_FR_BZH2',
111    );
112
113    my $l = DateTime::Locale->load('fr_FR_BZH2');
114    ok( $l, 'was able to load fr_FR_BZH2' );
115    is( $l->short_date_format, 'test test2', "short date" );
116    is( $l->name, 'French2 French2 Britanny2', 'name is also set' );
117}
118
119# with a custom namespace
120{
121    DateTime::Locale->register(
122        id           => 'fr_FR_BZH',
123        en_language  => 'French',
124        en_territory => 'French',
125        en_variant   => 'Britanny',
126        class        => 'Other::Locale::fr_FR_BZH',
127    );
128
129    my $l = DateTime::Locale->load('fr_FR_BZH');
130    ok( $l, 'was able to load fr_FR_BZH' );
131    is( $l->short_date_format, 'test test2',             "short date" );
132    is( $l->name,              'French French Britanny', 'name is also set' );
133}
134