File: 01_normal.t

package info (click to toggle)
libpoe-perl 2%3A1.3670-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,996 kB
  • ctags: 1,416
  • sloc: perl: 22,865; makefile: 9
file content (35 lines) | stat: -rw-r--r-- 929 bytes parent folder | download | duplicates (8)
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");