-
Notifications
You must be signed in to change notification settings - Fork 26
/
01_normal.t
35 lines (27 loc) · 929 Bytes
/
01_normal.t
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
# vim: ts=2 sw=2 filetype=perl expandtab
use Test::More tests => 7;
use POE;
POE::Session->create(
inline_states => {
_start => sub {
pass("Session started");
$_[KERNEL]->sig('DIE' => 'avoid_death');
$_[KERNEL]->yield('death');
$_[KERNEL]->delay('party' => 0.5);
},
_stop => sub { pass("Session stopping"); },
death => sub { die "OMG THEY CANCELLED FRIENDS"; },
avoid_death => sub {
my $signal = $_[ARG0];
my $data = $_[ARG1];
is($signal, 'DIE', 'Caught DIE signal');
is($data->{from_state}, '_start', 'Signal came from the correct state');
like($data->{error_str}, qr/OMG THEY CANCELLED FRIENDS/, 'error_str contains correct value');
$_[KERNEL]->sig(DIE => undef);
$_[KERNEL]->sig_handled();
},
party => sub { pass("Environment survived exception attempt"); },
},
);
POE::Kernel->run();
pass("POE environment shut down");