Acme-FSM

 view release on metacpan or  search on metacpan

t/base/query_switch.t  view on Meta::CPAN

# $Id: query_switch.t 484 2013-05-09 20:56:46Z whynot $
# Copyright 2012, 2013 Eric Pozharski <whynot@pozharski.name>
# GNU GPLv3
# AS-IS, NO-WARRANTY, HOPE-TO-BE-USEFUL

use strict;
use warnings;

package t::TestSuite::FSM;
use parent qw| Acme::FSM |;

sub push_push                    {
    my $bb        = shift @_;
    $bb->{MKS}    = shift @main::flags;
    $bb->{CS_RCS} = shift @_                                            if @_;
    return !0, shift @main::flags }

package t::TestSuite::switch;

sub new { bless { }, shift @_ }

sub push_push                    {
    my $bb          = shift @_;
    $bb->{jedi_vcs} = shift @main::flags;
    $bb->{gat}      = shift @_                                          if @_;
    return !0, shift @main::flags }

package main;
use version 0.77; our $VERSION = version->declare( v2.3.4 );

use t::TestSuite qw| :diag :wraps |;
use Test::More;

use Acme::FSM;
use List::Util qw| sum |;

our( $bb, $rc, $stderr );
our %st    = ( START => { switch => undef, });
my $method = q|query_switch|;

our( $lock, $tag );
our @flags =
qw| m_files     Chiocciola
    archipel  superversion
    mercurial Valdimontone
    surround_SCM     asvcs
    dcvs            Aquila
    so6            fastcst
    arx            Nicchio
    cvsnt   sourceanywhere
    opencm         Pantera
    cvs          codeville
    controltier      Torre
    rmtrcs       ic_manage |;

sub push_push                      {
    my $rc = shift @_;
    return sub                    {
    my $bb      = shift @_;
    $bb->{RCS}  = shift @main::flags;
    $bb->{CSSC} = shift @_                                              if @_;
    return $rc, shift @main::flags }}

my %plug = ( diag_level => 5 );
my $switch;

my @data =
([            q|{switch} isa (undef)|,
  [qw|                        fail |],
  sub {                  undef, { } },
  [                                 ],
  qr.\Q {START}{switch} !isa defined.                                 ],
 [                                           q|{switch} isa (SCALAR)|,
  [qw|                                                  fail noise |],
  sub {                                               \$method, { } },
  [                                                                 ],
                                                  qr.\Q isa (SCALAR)., 
  { noted => qr.(?m)\Q[query_switch]: {START}{switch} isa (SCALAR). } ],
 [                                    q|{switch} isa (Acme::FSM)|,
  [qw|                                         copy fail noise |],



( run in 2.001 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )