Acme-FSM
view release on metacpan or search on metacpan
t/state/stop.t view on Meta::CPAN
# $Id: stop.t 564 2025-02-13 21:33:15Z whynot $
# Copyright 2012, 2013, 2022 Eric Pozharski <whynot@pozharski.name>
# Copyright 2025 Eric Pozharski <wayside.ultimate@tuta.io>
# GNU GPLv3
# AS-IS, NO-WARRANTY, HOPE-TO-BE-USEFUL
use strict;
use warnings;
package main;
use version 0.77; our $VERSION = version->declare( v2.3.5 );
use t::TestSuite qw| :switches :run :diag |;
use Test::More;
use Acme::FSM;
our( %st, $stderr );
our @inbase = ( undef, q|Roffa| );
our @input = @inbase;
our %opts = ( source => \&AFSMTS_shift, diag_level => -t STDOUT ? 10 : 1 );
my %common =
( state => q|STOP|,
diag_level => $opts{diag_level},
namespace => undef,
source => $opts{source},
dumper => undef,
queue => [ undef ] );
my @data =
([ q|no {STOP}|,
[qw| |],
{ START => { switch => sub { 1 }, tturn => [qw| STOP DONE |]}},
qr.\Q[verify]: {STOP}(): record !isa defined . ],
[ q|no workload|,
[qw| |],
{ STOP => { }},
[ qr.\Q{STOP}(eturn): turn !isa defined .,
qr.\Q{STOP}{switch} !isa defined . ] ],
[ q|no {STOP}{switch}|,
[qw| |],
{ START =>
{ switch => sub { 1 }, tturn => [qw| workload DONE |]},
workload =>
{ switch => sub { 1 },
eturn => [qw| STOP offal |],
tturn => [qw| STOP applesauce |] } },
qr.\Q{STOP}{switch} !isa defined . ],
[ q|full-set of turns, no {STOP}{switch}|,
[qw| |],
{ STOP =>
{ eturn => [ ],
uturn => [ ],
tturn => [ ],
fturn => [ ],
turns => { } } },
qr.\Q{STOP}{switch} !isa defined . ],
[ q|[D](noise/noise)|,
[qw| |],
{ STOP =>
{ switch => \&AFSMTS_D,
eturn => [ ],
uturn => [ ],
tturn => [ ],
fturn => [ ],
turns => { } }},
qr.^die switch . ],
[ q|[T](noise/noise)|,
[qw| pass |],
{ STOP =>
{ switch => \&AFSMTS_T,
eturn => [qw| shamble baloney |],
tturn => [qw| bull bullshit |] } },
[[[qw| offal |], { %common, action => q|offal| }],
[[qw| applesauce |], { %common, action => q|applesauce| }] ] ],
[ q|[F](noise/noise)|,
[qw| pass eignore |],
{ STOP => { switch => \&AFSMTS_F, fturn => [qw| wander folderol |]}},
[[qw| applesauce |], { %common, action => q|applesauce| }] ],
[ q|[U](noise/noise)|,
[qw| pass eignore |],
{ STOP => { switch => \&AFSMTS_U, uturn => [qw| gibber claptrap |]}},
[[qw| applesauce |], { %common, action => q|applesauce| }] ],
[ q|[_](noise/noise)|,
[qw| pass eignore |],
{ STOP =>
{ switch => \&AFSMTS_T, turns => { 1 => [qw| drivel refuse |]}}},
[[qw| applesauce |], { %common, action => q|applesauce| }] ],
[ q|[workload:T](STOP/noise)|,
[qw| pass |],
{ workload =>
{ switch => sub { 1 },
eturn => [qw| STOP offal |],
tturn => [qw| STOP applesauce |] } },
( run in 3.592 seconds using v1.01-cache-2.11-cpan-5837b0d9d2c )