aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Phillips <david@yeah.nah.nz>2020-04-04 21:15:13 +1300
committerDavid Phillips <david@yeah.nah.nz>2020-04-04 21:15:13 +1300
commit19d96d0c8a7599350366ad8c3d13c8c74f46b4a6 (patch)
treef3dcf8eff0156b1d7fe94f1da8ae50e3d4ab27a3
parentbb50b299de382395bd2ff7099ae1f32db3fd7a7a (diff)
downloadidalius-test.tar.xz
Add test plan for Mentest
-rwxr-xr-xtest.pl2
-rw-r--r--test/TODO.md2
-rwxr-xr-xtest/test_men.t47
3 files changed, 49 insertions, 2 deletions
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(\&note, 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(\&note, 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(\&note, 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(\&note, 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");
+}