#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 4; use Mock::IRC; use Plugin::Men; my $irc = new Mock::IRC; my %config = ( chance => 100, ); Plugin::Men->configure(undef, undef, \%config, undef); # Simplest test case, just message that reads `men` { my $what = "men"; my $r = Plugin::Men->on_message(\¬e, undef, undef, $what, $what, $irc); ok($r =~ m/women.*children too/, "caught expected word"); } # Simple test case, mid-word { my $what = "foo comment bar"; my $r = Plugin::Men->on_message(\¬e, undef, undef, $what, $what, $irc); ok($r =~ m/comwoment.*comchildrent too/, "caught expected word"); } # Case preservation on surrounding word # XXX rethink this behaviour - shouldn't it preserve case on whole word? { my $what = "frongle COMMENT kleng"; my $r = Plugin::Men->on_message(\¬e, undef, undef, $what, $what, $irc); ok($r =~ m/COMwomenT.*COMchildrenT too/, "caught expected word"); } # UTF-8 support { my $what = "💯 testmen☭"; my $r = Plugin::Men->on_message(\¬e, undef, undef, $what, $what, $irc); # use utf8 after this point. Don't use it above, module does its own # conversion for now because of how POE::Component::IRC passes data in use utf8; ok($r =~ m/testwomen.*testchildren too/, "caught expected word"); }