]>
Commit | Line | Data |
---|---|---|
bb1da1df MG |
1 | #!/usr/bin/perl -w |
2 | use v5.14; | |
3 | use warnings; | |
4 | no warnings 'redefine'; | |
5 | ||
6 | use Test::More tests => 11; | |
7 | BEGIN { use_ok('App::Devbot') }; | |
8 | ||
9 | use POE; | |
10 | ||
11 | sub call_poe{ | |
12 | my ($func, @args)=@_; | |
13 | my @arglist; | |
14 | $arglist[ARG0 + $_]=$args[$_] for 0 .. $#args; | |
15 | $func->(@arglist) | |
16 | } | |
17 | ||
18 | sub set_test{ | |
19 | my ($expected, $testname) = @_; | |
20 | *App::Devbot::log_event = sub { shift; is "@_", $expected, $testname }; | |
21 | } | |
22 | ||
23 | *App::Devbot::mode_char = sub { ' ' }; | |
24 | ||
25 | set_test '< nick> Hello, world!', 'public'; | |
26 | call_poe \&App::Devbot::on_public, 'nick!user@host', ['#channel'], 'Hello, world!'; | |
27 | ||
28 | set_test '* nick nicked', 'action'; | |
29 | call_poe \&App::Devbot::on_ctcp_action, 'nick!user@host', ['#channel'], 'nicked'; | |
30 | ||
31 | set_test '-!- nick [user@host] has joined #channel', 'join'; | |
32 | call_poe \&App::Devbot::on_join, 'nick!user@host', '#channel'; | |
33 | ||
34 | set_test '-!- nick [user@host] has left #channel [Leaving!]', 'part'; | |
35 | call_poe \&App::Devbot::on_part, 'nick!user@host', '#channel', 'Leaving!'; | |
36 | ||
37 | set_test '-!- idiot was kicked from #channel by nick [no reason]', 'kick'; | |
38 | call_poe \&App::Devbot::on_kick, 'nick!user@host', '#channel', 'idiot', 'no reason'; | |
39 | ||
40 | set_test '-!- mode/#channel [+oo mgv mgvx] by ChanServ', 'mode'; | |
41 | call_poe \&App::Devbot::on_mode, 'ChanServ!user@host', '#channel', '+oo', 'mgv', 'mgvx'; | |
42 | ||
43 | set_test '-!- nick changed the topic of #channel to: Go away!', 'topic set'; | |
44 | call_poe \&App::Devbot::on_topic, 'nick!user@host', '#channel', 'Go away!'; | |
45 | ||
46 | set_test '-!- Topic unset by nick on #channel', 'topic unset'; | |
47 | call_poe \&App::Devbot::on_topic, 'nick!user@host', '#channel', ''; | |
48 | ||
49 | set_test '-!- nick is now known as newnick', 'nick'; | |
50 | call_poe \&App::Devbot::on_nick, 'nick!user@host', 'newnick', ['#channel']; | |
51 | ||
52 | set_test '-!- nick [user@host] has quit [Quitting]', 'quit'; | |
53 | call_poe \&App::Devbot::on_quit, 'nick!user@host', 'Quitting', ['#channel']; |