Permalink
Browse files

Made $type parameter for eq_irc() optional and default to 'rfc-1459'.…

… Also changed it to return False instead of Nil when not equal or arguments are undef. Added test to verify this.
  • Loading branch information...
1 parent 634a124 commit 11bbd1ea39e2e742c012b38b331bafceeb678874 @soh-cah-toa committed Aug 15, 2011
Showing with 14 additions and 5 deletions.
  1. +4 −4 lib/IRC/Utils.pm
  2. +10 −1 t/02-functions.t
View
@@ -383,11 +383,11 @@ sub lc_irc(Str $value is copy, Str $type = 'rfc1459') is export {
return $value;
}
-sub eq_irc(Str $first, Str $second, Str $type) is export {
- return if !$first.defined || !$second.defined;
+sub eq_irc(Str $first, Str $second, Str $type = 'rfc1459') is export {
+ return Bool::False if !$first.defined || !$second.defined;
- return Bool::True if lc_irc($first, $type) ~~ lc_irc($second, $type);
- return;
+ return Bool::True if lc_irc($first, $type) eq lc_irc($second, $type);
+ return Bool::False;
}
# vim: ft=perl6
View
@@ -3,7 +3,7 @@ use v6;
use Test;
use IRC::Utils;
-plan 8;
+plan 9;
# Test numeric_to_name()
{
@@ -65,6 +65,15 @@ plan 8;
is $lc_strict, '{soh|cah|toa}', 'One arg lc_irc() with "strict-rfc1459"';
}
+# Test eq_irc()
+{
+ my Str $uc = '[S0H~C4H~T04]';
+ my Str $lc = '{s0h~c4h~t04}';
+ my Bool $eq = eq_irc($uc, $lc);
+
+ ok $eq, 'eq_irc()';
+}
+
done;
# vim: ft=perl6

0 comments on commit 11bbd1e

Please sign in to comment.