line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package My::Module::Test::Geocode; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
74659
|
use 5.008; |
|
1
|
|
|
|
|
15
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use Exporter (); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
9
|
|
|
|
|
|
|
our @ISA = qw{ Exporter }; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
585
|
use Astro::App::Satpass2::Utils qw{ load_package }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
92
|
|
12
|
1
|
|
|
1
|
|
7
|
use Test::More 0.88; |
|
1
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
13
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = '0.051'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ setup geocode }; |
17
|
|
|
|
|
|
|
our @EXPORT = @EXPORT_OK; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $wrapper_class; |
20
|
|
|
|
|
|
|
my $wrapper_object; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub setup { |
23
|
1
|
|
|
1
|
1
|
87
|
( $wrapper_class ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
1
|
50
|
|
|
|
4
|
load_package( $wrapper_class ) |
26
|
|
|
|
|
|
|
or plan skip_all => "Unable to load $wrapper_class: $@"; |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
|
|
10
|
my $geocoder_class = $wrapper_class->GEOCODER_CLASS(); |
29
|
|
|
|
|
|
|
|
30
|
1
|
50
|
|
|
|
6
|
load_package( $geocoder_class ) |
31
|
|
|
|
|
|
|
or plan skip_all => "$geocoder_class not available"; |
32
|
|
|
|
|
|
|
|
33
|
0
|
0
|
|
|
|
|
load_package( 'LWP::UserAgent' ) |
34
|
|
|
|
|
|
|
or plan skip_all => 'LWP::UserAgent not available'; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $url = $wrapper_class->GEOCODER_SITE(); |
37
|
0
|
0
|
0
|
|
|
|
my $rslt = LWP::UserAgent->new()->get( $url ) |
38
|
|
|
|
|
|
|
or plan skip_all => "No access to $url: " . $@ || 'Unknown error'; |
39
|
0
|
0
|
|
|
|
|
$rslt->is_success |
40
|
|
|
|
|
|
|
or plan skip_all => "No access to $url: ", $rslt->status_line(); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
eval { |
43
|
0
|
|
|
|
|
|
$wrapper_object = $wrapper_class->new(); |
44
|
0
|
0
|
|
|
|
|
} or do { |
45
|
0
|
|
|
|
|
|
@_ = ( "Failed to instantiate $wrapper_class: $@" ); |
46
|
0
|
|
|
|
|
|
goto &fail; |
47
|
|
|
|
|
|
|
}; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
@_ = ( "Instantiate $wrapper_class" ); |
50
|
0
|
|
|
|
|
|
goto &pass; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub geocode { |
54
|
0
|
|
|
0
|
1
|
|
my ( $loc, $tests ) = @_; |
55
|
0
|
0
|
|
|
|
|
defined $tests |
56
|
|
|
|
|
|
|
or $tests = 1; |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
$wrapper_object |
59
|
|
|
|
|
|
|
or skip "$wrapper_class instantiation failed", 1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
() = eval { # Force eval() to be in list context. |
62
|
0
|
|
|
|
|
|
$wrapper_object->geocode( $loc ) |
63
|
0
|
0
|
|
|
|
|
} and do { |
64
|
0
|
|
|
|
|
|
@_ = ( "Geocode '$loc'" ); |
65
|
0
|
|
|
|
|
|
goto &pass; |
66
|
|
|
|
|
|
|
}; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $resp = $wrapper_object->geocoder()->response(); |
69
|
0
|
|
|
|
|
|
my $msg = sprintf '%s - %s', |
70
|
|
|
|
|
|
|
$wrapper_object->GEOCODER_SITE(), |
71
|
|
|
|
|
|
|
$resp->status_line(); |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
500 == $resp->code() |
74
|
|
|
|
|
|
|
and skip $msg, $tests; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
@_ = ( $msg ); |
77
|
0
|
|
|
|
|
|
goto &fail; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |