blib/lib/POE/Test/Loops/z_steinert_signal_integrity.pm untested

filter: Statementstmt 0.0% 0 / 29 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 6 totaltotal 0.0% 0 / 55 CC 3 SCAR 11.7
CC
3
Cov
0%
BEGIN
6.0
setup
6.0
POE::Kernel::ASSERT_DEFAULT
2.0
CRAP 3.2
1 #!/usr/bin/perl -w
2 # vim: ts=2 sw=2 expandtab
3  
4 # Jonathan Steinert produced a patch to fix POE::Wheel destruction
5 # timing, and possibly other things, when they're passed as arguments
6 # to an event handler. It didn't take into consideration a subtle and
7 # obscure aspect of recursive signal dispatch. This regression test
8 # makes sure nested signal dispatches receive the proper parameters.
9  
10 use strict;
11  
12 sub POE::Kernel::ASSERT_DEFAULT () { 1 }
13  
14 BEGIN {
15 eval "sub POE::Kernel::TRACE_DEFAULT () { 1 }" if (
16 exists $INC{'Devel/Cover.pm'}
17 );
18 }
19  
20 use POE;
21 use POE::Wheel::ReadWrite;
22 use POE::Pipe::OneWay;
23  
24 use Test::More tests => 2;
25  
26 my $session_count = 0;
27  
28 sub start_session {
29 $session_count++;
30 POE::Session->create(
31 inline_states => {
32 _start => \&setup,
33 got_signal => \&handle_signal,
34 timed_out => \&timed_out,
35 # To pacify assertions.
36 _stop => sub { },
37 _parent => sub { },
38 _child => sub { },
39 }
40 );
41 }
42  
43 start_session();
44 $poe_kernel->signal($poe_kernel, MOO => 99);
45 POE::Kernel->run();
46  
47 ### End of main code. Beginning of subroutines.
48  
49 sub setup {
50 start_session() if $session_count < 2;
51 $_[KERNEL]->sig(MOO => "got_signal");
52 $_[KERNEL]->delay(timed_out => 2);
53 }
54  
55 sub handle_signal {
56 ok(
57 ($_[ARG0] eq "MOO") &&
58 ($_[ARG1] == 99),
59 "signal parameters: ('$_[ARG0]' eq 'MOO', $_[ARG1] == 99)"
60 );
61  
62 # Wait just a little bit, in case of spurious signal.
63 POE::Kernel->delay( timed_out => 0.250 );
64 }
65  
66 sub timed_out {
67 $_[KERNEL]->sig(MOO => undef);
68 }
69  
70 1;