From 19d96d0c8a7599350366ad8c3d13c8c74f46b4a6 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Sat, 4 Apr 2020 21:15:13 +1300 Subject: Add test plan for Men --- test.pl | 2 +- test/TODO.md | 2 +- test/test_men.t | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100755 test/test_men.t diff --git a/test.pl b/test.pl index b819e0e..69b1e60 100755 --- a/test.pl +++ b/test.pl @@ -3,7 +3,7 @@ use Test::Harness; my @tests = map {"test/test_$_.t"} qw/ - autojoin echo ping random thanks vote + autojoin echo men ping random thanks vote /; runtests(@tests); diff --git a/test/TODO.md b/test/TODO.md index 2dc857d..1972e47 100644 --- a/test/TODO.md +++ b/test/TODO.md @@ -16,7 +16,6 @@ * Log.pm * Map.pm * Markov.pm -* Men.pm * Natural.pm * Quote_Grab.pm * Source.pm @@ -30,6 +29,7 @@ * Autojoin.pm * Echo.pm +* Men.pm * Ping.pm * Random.pm * Thanks.pm diff --git a/test/test_men.t b/test/test_men.t new file mode 100755 index 0000000..683accd --- /dev/null +++ b/test/test_men.t @@ -0,0 +1,47 @@ +#!/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"); +} -- cgit v1.1