Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 81 lines (58 sloc) 1.576 kB
fb56d61 @perigrin clean up the top of the tests
authored
1 #!/usr/bin/env perl
acd9216 @apocalypse add strict/warnings to all testfiles
apocalypse authored
2 use strict; use warnings;
c76e0ea @nothingmuch role support for MooseX::POE + the aliased role
nothingmuch authored
3
877feac @apocalypse fix aliased to not throw warnings and make it really test ASSERT_DEFAULT
apocalypse authored
4 use Test::More tests => 6;
c7c2a60 @perigrin swap Test::Exception for Test::Fatal
authored
5 use Test::Fatal;
c76e0ea @nothingmuch role support for MooseX::POE + the aliased role
nothingmuch authored
6
7 use POE;
8
9 my @log;
10
11 {
fe6fe4e @perigrin add test from LordVorp for aliased with ASSERT_DEFAULT
authored
12
c76e0ea @nothingmuch role support for MooseX::POE + the aliased role
nothingmuch authored
13 package Foo;
14 use MooseX::POE;
15
16 with qw(MooseX::POE::Aliased);
17
18 event foo => sub {
fe6fe4e @perigrin add test from LordVorp for aliased with ASSERT_DEFAULT
authored
19 push @log, [ @_[ ARG0 .. $#_ ] ];
c76e0ea @nothingmuch role support for MooseX::POE + the aliased role
nothingmuch authored
20 };
21 }
cd2f908 @ashb Add a constructor meta trait so we can inling things. Needs git versi…
ashb authored
22 {
fe6fe4e @perigrin add test from LordVorp for aliased with ASSERT_DEFAULT
authored
23
cd2f908 @ashb Add a constructor meta trait so we can inling things. Needs git versi…
ashb authored
24 package ImmutableFoo;
25 use MooseX::POE;
26
27 with qw(MooseX::POE::Aliased);
28
29 event foo => sub {
fe6fe4e @perigrin add test from LordVorp for aliased with ASSERT_DEFAULT
authored
30 push @log, [ @_[ ARG0 .. $#_ ] ];
cd2f908 @ashb Add a constructor meta trait so we can inling things. Needs git versi…
ashb authored
31 };
32
c7c2a60 @perigrin swap Test::Exception for Test::Fatal
authored
33 __PACKAGE__->meta->make_immutable( inline_constructor => 0 );
cd2f908 @ashb Add a constructor meta trait so we can inling things. Needs git versi…
ashb authored
34 }
c76e0ea @nothingmuch role support for MooseX::POE + the aliased role
nothingmuch authored
35
36 my $foo = Foo->new( alias => "blah" );
37
38 POE::Session->create(
39 inline_states => {
40 _start => sub {
41 $_[KERNEL]->yield("blah");
42 },
43 blah => sub {
44 $_[KERNEL]->post( blah => foo => "this" );
45 $foo->alias("bar");
46 $_[KERNEL]->post( bar => foo => "that" );
47 },
48 }
49 );
50
c7c2a60 @perigrin swap Test::Exception for Test::Fatal
authored
51 POE::Kernel->run;
c76e0ea @nothingmuch role support for MooseX::POE + the aliased role
nothingmuch authored
52
53 is( scalar(@log), 2, "two events" );
54
55 is_deeply( $log[0], ["this"], "first event under alias 'blah'" );
56 is_deeply( $log[1], ["that"], "second event under alias 'bar'" );
cd2f908 @ashb Add a constructor meta trait so we can inling things. Needs git versi…
ashb authored
57
58 @log = ();
59 $foo = ImmutableFoo->new( alias => "blah" );
60
61 POE::Session->create(
62 inline_states => {
63 _start => sub {
64 $_[KERNEL]->yield("blah");
65 },
66 blah => sub {
67 $_[KERNEL]->post( blah => foo => "this" );
68 $foo->alias("bar");
69 $_[KERNEL]->post( bar => foo => "that" );
70 },
71 }
72 );
73
c7c2a60 @perigrin swap Test::Exception for Test::Fatal
authored
74 POE::Kernel->run;
cd2f908 @ashb Add a constructor meta trait so we can inling things. Needs git versi…
ashb authored
75
76 is( scalar(@log), 2, "two events" );
77
78 is_deeply( $log[0], ["this"], "first event under alias 'blah'" );
79 is_deeply( $log[1], ["that"], "second event under alias 'bar'" );
80
Something went wrong with that request. Please try again.