Use Unicode::Normalize
[poe-component-irc-plugin-hello.git] / t / POE-Component-IRC-Plugin-Hello.t
CommitLineData
b2f492fe 1#!/usr/bin/perl -w
29280d6c
MG
2use v5.14;
3use strict;
4use warnings;
5
828747eb 6use Test::More tests => 19;
29280d6c
MG
7use Test::MockObject;
8
9BEGIN { use_ok('POE::Component::IRC::Plugin::Hello') };
10
29280d6c
MG
11my $hello_sent;
12
13my $mockirc = Test::MockObject->new;
14$mockirc->mock(yield => sub { $hello_sent = 1 })->set_always(nick_name => 'hellobot');
15
16my $self = POE::Component::IRC::Plugin::Hello->new;
17my $channels = [ '#chan' ];
18
29280d6c 19sub runtest{
9e1acbcb
MG
20 my ($message, $expect, $comment) = @_;
21 $hello_sent=0;
22 $self->S_public($mockirc, \'mgv!marius@ieval.ro', \$channels, \$message);
23 ok($hello_sent == $expect, $comment)
29280d6c
MG
24}
25
29280d6c
MG
26runtest 'privet', 1, 'simple privet';
27runtest 'PrIvEt', 1, 'privet in mixed case';
28runtest ' privet ', 1, 'privet with spaces';
29runtest 'hellobot: privet', 1, 'addressed privet';
30runtest 'hellobot: privet ', 1, 'addressed privet with spaces';
28c96441
MG
31runtest 'privet!', 1, 'privet with exclamation mark';
32runtest 'privet.', 1, 'privet with full stop';
29280d6c
MG
33runtest 'ahoy', 1, 'ahoy';
34runtest 'namaste', 1, 'namaste';
35runtest 'neaţa', 1, 'neaţa (UTF-8 test)';
36runtest 'こんにちは', 1, 'こんにちは (another UTF-8 test)';
828747eb 37runtest 'neața', 1, 'neața (UTF-8 with combining comma below)';
29280d6c
MG
38
39runtest 'salu', 0, 'salu (misspelling)';
40runtest 'hii', 0, 'hii (misspelling)';
41runtest 'neaţa mgv', 0, 'neaţa mgv (valid greeting with garbage after it)';
28c96441 42runtest 'hi,', 0, 'hi, (bad punctuation)';
29280d6c
MG
43
44$self = POE::Component::IRC::Plugin::Hello->new(greetings => ['sayonara']);
29280d6c
MG
45runtest 'privet', 0, 'custom greetings - privet';
46runtest ' sayonara ', 1, 'custom greetings - sayonara';
This page took 0.013675 seconds and 4 git commands to generate.