File: country-for-subclass.t

package info (click to toggle)
libnumber-phone-perl 3.6006-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 136,072 kB
  • sloc: perl: 2,719; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 926 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
use strict;
use warnings;
use Test::More;

END { done_testing(); }

use lib 't/inc';
use fatalwarnings;

use Number::Phone;

{
    package Number::Phone::UK::SubClass;
    use base 'Number::Phone::UK';
    #sub new { bless {}, shift }
}

is(Number::Phone->new('+1 2684601234')->country, 'AG', 'Basic country() check for NANP::AG');
is(Number::Phone->new('+44 142422 0000')->country, 'UK', 'Basic country() check for UK');
is(Number::Phone->new('+43 1 21145 2358')->country, 'AT', 'Basic country() check for AT');
is(Number::Phone::UK->new('+44 142422 0000')->country, 'UK', 'Basic country() check for UK');
my $num = Number::Phone::UK::SubClass->new('+44 142422 0000');
# Because we really want to test the base implementation in Number::Phone...
is $num->can('country'), \&Number::Phone::country, 'UK does not override ->country';

# The real aim of this test file
is($num->country, 'UK', 'A subclass of UK, but still UK');