use strict;use warnings FATAL =>qw(all); use lib './lib'; use Test::More; use Blacknote::Interface; my $state = Blacknote::Interface::State->new( name => 'state 1', init => sub { note "running state 1 init" }, update => sub { note "update state 1"; return "state 2"}, fini => sub { note "Running state 1 fini"}, ); ok defined $state; isa_ok $state, "Blacknote::Interface::State"; isa_ok $state, "Blacknote::Interface::IState"; note explain $state; can_ok $state, qw(name init update fini); defsm TestSM => ( $state, Blacknote::Interface::State->new( name => 'state 2', init => sub { note "This is jsut the init method of a second state object" }, update => sub { note "state 2 update" }, fini => sub {} ) ); my $sm = TestSM->new; can_ok $sm, qw(init new cycle _cycles fini etc valid_states switch_state); $sm->init; $sm->cycle; ok $sm->get_state->name eq "state 2"; $sm->cycle; $sm->fini; done_testing; .