File: ton-stop-corruption.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 (50 lines) | stat: -rw-r--r-- 1,055 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

# Test that stop() does not result in a double garbage collection on
# the session that called it.  This test case provided by Ton Hospel.

use strict;

use Test::More tests => 5;

sub POE::Kernel::ASSERT_DEFAULT () { 1 }

BEGIN {
  package POE::Kernel;
  use constant TRACE_DEFAULT => exists($INC{'Devel/Cover.pm'});
}

BEGIN { use_ok("POE") }
BEGIN { use_ok("POE::Pipe::OneWay") }

BEGIN { $^W = 1 };

my ($rd, $wr) = POE::Pipe::OneWay->new();
ok(defined($rd), "created a pipe for testing ($!)");

my $stop_was_called = 0;

POE::Session->create(
  inline_states => {
    _start       => sub {
      $poe_kernel->select_read($rd, "readable");
    },
    readable     => sub {
      pass("got readable callback; calling stop");
      $poe_kernel->select_read($rd);
      $poe_kernel->stop();
    },
    _stop   => sub { $stop_was_called++ },
    _parent => sub { },
    _child  => sub { },
  }
);

close $wr;

POE::Kernel->run();

is( $stop_was_called, 1, "stop was only called once" );

exit;