File: 25client-commands.t

package info (click to toggle)
libprotocol-irc-perl 0.13-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 264 kB
  • sloc: perl: 2,122; makefile: 2
file content (44 lines) | stat: -rw-r--r-- 1,229 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl

use v5.14;
use warnings;

use Test::More;

my @written;

package TestIRC {
   use base qw( Protocol::IRC::Client );

   sub new { return bless {}, shift }

   sub write { $_[1] =~ s/\x0d\x0a$//; push @written, $_[1] }
}

my $irc = TestIRC->new;

# PRIVMSG
{
   $irc->do_PRIVMSG( target => "#channel", text => "message 1" );
   is( shift @written, "PRIVMSG #channel :message 1", 'do_PRIVMSG renames target' );

   $irc->do_PRIVMSG( targets => "#channel", text => "message 2" );
   is( shift @written, "PRIVMSG #channel :message 2", 'do_PRIVMSG preserves targets' );

   $irc->do_PRIVMSG( targets => [ "#a", "#b" ], text => "message 3" );
   is( shift @written, "PRIVMSG #a,#b :message 3", 'do_PRIVMSG joins targets ARRAY' );
}

# NOTICE
{
   $irc->do_NOTICE( target => "#channel", text => "message 1" );
   is( shift @written, "NOTICE #channel :message 1", 'do_NOTICE renames target' );

   $irc->do_NOTICE( targets => "#channel", text => "message 2" );
   is( shift @written, "NOTICE #channel :message 2", 'do_NOTICE preserves targets' );

   $irc->do_NOTICE( targets => [ "#a", "#b" ], text => "message 3" );
   is( shift @written, "NOTICE #a,#b :message 3", 'do_NOTICE joins targets ARRAY' );
}

done_testing;