Acme-FSM

 view release on metacpan or  search on metacpan

t/state/workload.t  view on Meta::CPAN

# $Id: workload.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.4 );

use t::TestSuite qw| :switches :run :diag |;
use Test::More;

use Acme::FSM;

our( %st, $stderr, @input );
our @inbase = q|Marriner|;
our %opts   = ( source => \&AFSMTS_shift, diag_level => -t STDOUT ? 10 : 1 );

sub toggle_now ( ) {
    @inbase = $inbase[0] ? ( undef ) x 5 :
  qw| Amelia_Ducat Delta_Magna Stegnos Davros Mawdryn |;
    @input = ( )    }

my %cache =
( tstart => { switch => sub {     1 }, tturn => [ q|workload| ]},
  fstart => { switch => sub {     0 }, fturn => [ q|workload| ]},
  ustart => { switch => sub { undef }, uturn => [ q|workload| ]} );

my @data =
([                               q|no {START}{tturn}{action}|,
  [qw|                                                     |],
  { START     =>
    { switch => sub { 1 }, tturn => [ q|workload|, undef ]},
    workload  => {                   switch => \&AFSMTS_D } },
  [ qr.\Q{workload}(eturn): turn !isa defined .,
                               qr.^die switch .             ]          ],
 [                               q|no {START}{fturn}{action}|,
  [qw|                                             eignore |],
  { START     =>
    { switch => sub { 0 }, fturn => [ q|workload|, undef ]},
    workload  => {                   switch => \&AFSMTS_D } },
                                             qr.^die switch .          ],
 [                                   q|no {START}{uturn}{action}|,
  [qw|                                                 eignore |],
  { START     =>
    { switch => sub { undef }, uturn => [ q|workload|, undef ]},
    workload  => {                       switch => \&AFSMTS_D } },
                                                 qr.^die switch .      ],
 [                        q|unknown {START}{tturn}{action}|,
  [qw|                                                   |],
  { START     =>
    { switch => sub { 1 }, tturn => [qw| workload XIV |]},
    workload  => {                 switch => \&AFSMTS_D } },
  [ qr.\Q{workload}(eturn): turn !isa defined .,
                               qr.^die switch .           ]            ],
 [                        q|unknown {START}{fturn}{action}|,
  [qw|                                           eignore |],
  { START     =>
    { switch => sub { 0 }, fturn => [qw| workload XIV |]},
    workload  => {                 switch => \&AFSMTS_D } },
                                           qr.^die switch .            ],
 [                            q|unknown {START}{uturn}{action}|,
  [qw|                                               eignore |],
  { START     =>
    { switch => sub { undef }, uturn => [qw| workload XIV |]},
    workload  => {                     switch => \&AFSMTS_D } },
                                               qr.^die switch .        ],
 [                        q|no {workload}(tturn)|,
  [qw|                                         |],
  { workload => {                              }},
  [ qr.\Q{workload}(eturn): turn !isa defined .,
         qr.\Q{workload}{switch} !isa defined . ]                      ],
 [                    q|no {workload}(fturn)|,
  [qw|                             eignore |],
  { workload => {                          }},
       qr.\Q{workload}{switch} !isa defined .                          ],
 [                    q|no {workload}(uturn)|,
  [qw|                             eignore |],
  { workload => {                          }},
       qr.\Q{workload}{switch} !isa defined .                          ],
 [                                     q|malformed {workload}(tturn)|,
  [qw|                                                             |],
  { workload  => 
    { switch => \&AFSMTS_T, eturn => q|MDCXLV|, tturn => q|MMCCXV| }},
  [ qr.\Q{workload}(eturn): turn isa (), should be (ARRAY) .,
    qr.\Q{workload}(tturn): turn isa (), should be (ARRAY) .        ]  ],
 [                             q|malformed {workload}(fturn)|,



( run in 1.812 second using v1.01-cache-2.11-cpan-39bf76dae61 )