Geo-Coder-List

 view release on metacpan or  search on metacpan

t/function.t  view on Meta::CPAN

# =============================================================================

subtest 'reverse_geocode: anything but a numeric pair croaks before any backend' => sub {
	# Purpose: a malformed latlng would be split into nonsense coordinates
	# and sent to every backend in the chain
	my $calls = 0;
	my $list  = _make_list(MockGeocoder::Alpha->new());
	my $m     = mock_scoped 'MockGeocoder::Alpha::reverse_geocode' => _counting(\$calls, { display_name => 'X' });

	my @bad = (
		'abc', '51.5', '51.5,', ',-0.1', '1,2,3', '51.5;-0.1', 'NaN,NaN',
		'1e5,2', "51.5,-0.1\n; rm -rf /", '51.5 -0.1', [ 51.5, -0.1 ],
	);
	for my $latlng (@bad) {
		throws_ok { $list->reverse_geocode(latlng => $latlng) }
			qr/^\Q$MSG_RG_USAGE\E/,
			'refused: ' . (ref($latlng) ? 'array ref' : "'$latlng'");
	}
	is($calls, 0, 'the backend was never asked');
};



( run in 2.074 seconds using v1.01-cache-2.11-cpan-60884a8df76 )