File: rt14444-arg1.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 (45 lines) | stat: -rw-r--r-- 998 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
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl
# vim: ts=2 sw=2 filetype=perl expandtab

use warnings;
use strict;

use POE;
use Test::More tests => 3;

my $test_state  = "some_random_state";
my @test_args   = qw(some random args);

POE::Session->create(
  inline_states => {
    _start => sub {
      $_[KERNEL]->yield($test_state, @test_args);
    },
    _default => sub {
      my ($orig_state, $orig_args) = @_[ARG0,ARG1];
      if ($orig_state eq $test_state) {
        is_deeply(\@test_args, $orig_args, "test args passed okay");
      }

      $_[KERNEL]->yield( check_ref  => $_[ARG1]      );
      $_[KERNEL]->yield( check_copy => [@{$_[ARG1]}] );
    },
    check_ref => sub {
      my $test_args = $_[ARG0];
      is_deeply(
        \@test_args, $test_args,
        "args preserved in pass by reference",
      );
    },
    check_copy => sub {
      my $test_args = $_[ARG0];
      is_deeply(
        \@test_args, $test_args,
        "args preserved in pass by copy",
      );
    }
  }
);

POE::Kernel->run;
exit 0;