File: 05_robot.t

package info (click to toggle)
libhttp-browserdetect-perl 3.41-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,220 kB
  • sloc: perl: 3,083; makefile: 2
file content (47 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download
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();