Acme-FSM
view release on metacpan or search on metacpan
t/state/break.t view on Meta::CPAN
# $Id: break.t 564 2025-02-13 21:33:15Z whynot $
# Copyright 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|CONTINUE|,
diag_level => $opts{diag_level},
namespace => undef,
source => $opts{source},
dumper => undef,
queue => [ undef ] );
my @data =
([ q|no {BREAK}|,
[qw| |],
{ START => { switch => sub { 1 }, tturn => [qw| BREAK DONE |]}},
qr.\Q[verify]: {BREAK}(): record !isa defined . ],
[ q|no workload|,
[qw| |],
{ BREAK => { }},
[ qr.\Q{BREAK}(eturn): turn !isa defined .,
qr.\Q{switch} !isa defined . ] ],
[ q|[T], no {BREAK}{switch}|,
[qw| eignore |],
{ START => { switch => sub { 1 }, tturn => [qw| workload |]},
workload =>
{ switch => sub { 1 }, tturn => [qw| BREAK DONE |] } },
qr.\Q{BREAK}{switch} !isa defined . ],
[ q|[F], no {BREAK}{switch}|,
[qw| eignore |],
{ workload =>
{ switch => sub { 0 }, fturn => [qw| BREAK DONE |] }},
qr.\Q{BREAK}{switch} !isa defined . ],
[ q|[U], no {BREAK}{switch}|,
[qw| eignore |],
{ workload =>
{ switch => sub { undef }, uturn => [qw| BREAK DONE |] }},
qr.\Q{BREAK}{switch} !isa defined . ],
[ q|[_], no {BREAK}{switch}|,
[qw| |],
{ workload =>
{ switch => sub { 1 },
eturn => [qw| BREAK FAIL |],
turns => { 1 => [qw| BREAK DONE |]} }},
qr.\Q{BREAK}{switch} !isa defined . ],
[ q|full-set of turns, no {BREAK}{switch}|,
[qw| |],
{ BREAK =>
{ eturn => [ ],
uturn => [ ],
tturn => [ ],
fturn => [ ],
turns => { } }},
qr.\Q{BREAK}{switch} !isa defined . ],
[ q|[D]|,
[qw| |],
{ BREAK => { switch => \&AFSMTS_D }},
qr.^die switch . ],
[ q|[D](noise/noise)x4|,
[qw| |],
{ BREAK =>
{ switch => \&AFSMTS_D,
eturn => [ ],
uturn => [ ],
tturn => [ ],
fturn => [ ],
turns => { } }},
qr.^die switch . ],
[ q|[T](noise/noise)|,
[qw| pass |],
{ BREAK =>
{ switch => \&AFSMTS_T,
eturn => [qw| stabce ace432 |],
tturn => [qw| st7b10 ac3bca |] }},
[[[qw| FAIL |], { %common, action => q|FAIL| }],
[[qw| DONE |], { %common, action => q|DONE| }] ] ],
[ q|[F](noise/noise)|,
( run in 1.635 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )