File: 08_parent_session.t

package info (click to toggle)
libpoe-component-irc-perl 6.93%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, trixie
  • size: 1,532 kB
  • sloc: perl: 16,219; makefile: 5
file content (33 lines) | stat: -rw-r--r-- 816 bytes parent folder | download | duplicates (5)
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
# This tests the following from IRC.pm's pod:
#
# Starting with version 4.96, if you spawn the component from inside another
# POE session, the component will automatically register that session as
# wanting 'all' irc events. That session will receive an irc_registered
# event indicating that the component is up and ready to go.

use strict;
use warnings FATAL => 'all';
use POE;
use POE::Component::IRC;
use Test::More tests => 2;

POE::Session->create(
    package_states => [
        main => [qw(_start irc_registered)],
    ],
);

$poe_kernel->run();

sub _start {
    my ($heap) = $_[HEAP];
    $heap->{irc} = POE::Component::IRC->spawn();
}

sub irc_registered {
    my ($heap, $irc) = @_[HEAP, ARG0];
    pass('Child registered us');
    isa_ok($irc, 'POE::Component::IRC');
    $irc->yield('shutdown');
}