Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

64 lines (49 sloc) 1.592 kB
use strict;
# vim: ts=2 sw=2 filetype=perl expandtab
package main;
use Test::More tests => 11;
use POE::NFA;
my $nfa;
eval {
POE::NFA->spawn('foo')
};
like($@, qr/odd number/, 'NFA treats its params as a hash');
eval {
POE::NFA->spawn(inline_states => {initial => { start => sub { 0 } } })
};
like($@, qr/requires a working Kernel/, 'NFA needs a working kernel');
eval "use POE::Kernel";
eval {
POE::NFA->spawn(crap => 'foo');
};
like($@, qr/constructor requires at least one of/, 'need states');
eval {
$nfa = POE::NFA->spawn(inline_states => {initial => { start => sub { 0 } } })
};
isa_ok($nfa, 'POE::NFA', 'most basic machine');
eval {
POE::NFA->spawn(inline_states => {initial => { start => sub { 0 } } }, crap => 'foo')
};
like($@, qr/constructor does not recognize/, 'unknown parameter');
eval {
POE::NFA->spawn(package_states => {initial => 'foo'});
};
like($@, qr/the data for state/, 'bad state data');
eval {
POE::NFA->spawn(package_states => {initial => ['Foo']});
};
like($@, qr/the array for state/, 'bad state data');
eval {
POE::NFA->spawn(package_states => {initial => ['Foo' => 'bar']});
};
like($@, qr/need to be a hash or array ref/, 'bad event data');
eval {
$nfa = POE::NFA->spawn(package_states => {initial => ['Foo' => [qw(foo bar)]]});
};
isa_ok($nfa, 'POE::NFA', 'spawn with package_states');
eval {
$nfa = POE::NFA->spawn(package_states => {initial => ['Foo' => [qw(foo bar)]]}, runstate => [ ] );
};
isa_ok($nfa, 'POE::NFA', 'spawn with package_states');
is( ref $nfa->[0], 'ARRAY', 'RUNSTATE is an ARRAYREF' );
POE::Kernel->run;
Jump to Line
Something went wrong with that request. Please try again.