X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=t%2FPOE-Component-IRC-Plugin-Infobot.t;h=8846b8313a90dcf89e516636cad3e5bfb70b12d3;hb=HEAD;hp=90723a987817b4d4c52988ee68a5bf3fc4a0bb11;hpb=30023d128d2cf9f2d3eb54e21b9d56779478caa3;p=poe-component-irc-plugin-infobot.git diff --git a/t/POE-Component-IRC-Plugin-Infobot.t b/t/POE-Component-IRC-Plugin-Infobot.t index 90723a9..8846b83 100644 --- a/t/POE-Component-IRC-Plugin-Infobot.t +++ b/t/POE-Component-IRC-Plugin-Infobot.t @@ -2,16 +2,15 @@ use strict; use warnings; -use Taint::Util qw/taint/; use Test::MockObject; -use Test::More tests => 16; +use Test::More tests => 17; BEGIN { use_ok('POE::Component::IRC::Plugin::Infobot') }; no warnings 'redefine'; sub POE::Component::IRC::Plugin::Infobot::getstr { - my $rstrings = shift; - sprintf @{$rstrings}[0], @_ + my $rstrings = shift; + sprintf @{$rstrings}[0], @_ } use warnings 'redefine'; @@ -19,8 +18,8 @@ my $last_msg; my $last_ctcp; sub yield { - $last_msg = $_[3] if $_[1] eq 'privmsg'; - $last_ctcp = $_[3] if $_[1] eq 'ctcp'; + $last_msg = $_[3] if $_[1] eq 'privmsg'; + $last_ctcp = $_[3] if $_[1] eq 'ctcp'; } my $mockirc = Test::MockObject->new; @@ -29,12 +28,12 @@ $mockirc->mock(yield => \&yield)->set_always(nick_name => 'bot'); my $self = POE::Component::IRC::Plugin::Infobot->new(filename => undef); sub runtest{ - my ($message, $expect, $comment, $private) = @_; - undef $last_msg; - undef $last_ctcp; - $self->S_public($mockirc, \'mgv!marius@ieval.ro', \([ '#chan' ]), \$message) unless $private; - $self->S_msg($mockirc, \'mgv!marius@ieval.ro', undef, \$message) if $private; - is($last_msg // $last_ctcp, $expect, $comment) + my ($message, $expect, $comment, $private) = @_; + undef $last_msg; + undef $last_ctcp; + $self->S_public($mockirc, \'mgv!marius@ieval.ro', \([ '#chan' ]), \$message) unless $private; + $self->S_msg($mockirc, \'mgv!marius@ieval.ro', undef, \$message) if $private; + is($last_msg // $last_ctcp, $expect, $comment) } runtest 'bot: a is b', 'sure, mgv', 'add'; @@ -43,6 +42,7 @@ runtest 'bot: a is c', '... but a is b!', 'redefine factoid'; runtest 'a?', 'a is b', 'query'; runtest 'bot: forget a', 'mgv: I forgot a', 'forget'; runtest 'bot: forget a', 'I didn\'t have anything matching a, mgv', 'forget inexistent factoid'; +runtest '!forget a', 'I didn\'t have anything matching a, mgv', '!forget'; runtest 'a?', undef, 'query for inexistent factoid'; runtest 'bot: a?', 'I don\'t know, mgv', 'addressed query for inexistent factoid';