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
|
#!perl
use strict;
use warnings;
use HTTP::BrowserDetect ();
use List::Util qw( any );
use Test::More import => [qw( done_testing is ok subtest unlike )];
my $detect = HTTP::BrowserDetect->new;
my %names = $detect->_robot_names;
my @ids = $detect->all_robot_ids;
my %fixup = $detect->_robot_ids;
is( scalar @ids, 76, 'correct number of ids' );
foreach my $id (@ids) {
subtest $id => sub {
ok( $names{$id}, 'name' );
unlike(
$id, qr{[^0-9a-z-]}mxs,
'id contains only lower case letters or dashes'
);
};
}
my @tests = $detect->_robot_tests;
for my $test (@tests) {
my $id = $test->[1];
subtest "$id check" => sub {
unlike(
$id, qr{[^0-9a-z-]},
"$id contains only lower case letters or dashes"
);
ok(
( any { $_ eq $id } @ids ),
"$id found in all_robot_ids()"
);
};
}
for my $id ( values %fixup ) {
ok( $names{$id}, "$id exists in names list" );
}
done_testing();
|