line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package LiBot::Test::Handler; |
2
|
2
|
|
|
2
|
|
79611
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
101
|
|
3
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
63
|
|
4
|
2
|
|
|
2
|
|
12
|
use utf8; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
16
|
|
5
|
2
|
|
|
2
|
|
579
|
use LiBot; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
59
|
|
6
|
2
|
|
|
2
|
|
16
|
use Test::More; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
26
|
|
7
|
2
|
|
|
2
|
|
725
|
use re qw(is_regexp regexp_pattern); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
453
|
|
8
|
2
|
|
|
2
|
|
2063
|
use parent qw(Exporter); |
|
2
|
|
|
|
|
658
|
|
|
2
|
|
|
|
|
12
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @EXPORT = qw(load_plugin test_message); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $BOT = LiBot->new(); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub load_plugin { |
15
|
1
|
|
|
1
|
0
|
15
|
$BOT->load_plugin(@_); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub test_message { |
19
|
2
|
|
|
2
|
0
|
18
|
my ($msg, $pattern) = @_; |
20
|
|
|
|
|
|
|
|
21
|
2
|
50
|
|
|
|
10
|
unless (ref $msg) { |
22
|
2
|
50
|
|
|
|
45
|
if ($msg =~ /\A<([^>]+)>\s+(.+)\z/) { |
23
|
2
|
|
|
|
|
29
|
$msg = LiBot::Message->new( |
24
|
|
|
|
|
|
|
nickname => $1, |
25
|
|
|
|
|
|
|
text => $2, |
26
|
|
|
|
|
|
|
) |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$BOT->handle_message(sub { |
31
|
2
|
50
|
|
2
|
|
25
|
if (is_regexp($pattern)) { |
32
|
0
|
|
|
|
|
0
|
like($_[0], $pattern); |
33
|
|
|
|
|
|
|
} else { |
34
|
2
|
|
|
|
|
17
|
is($_[0], $pattern); |
35
|
|
|
|
|
|
|
} |
36
|
2
|
|
|
|
|
98
|
}, $msg); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
__END__ |