Verify/Move.pm

filter: Statementstmt 98.0% 50 / 51 Branchbran 92.8% 13 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 97.1% 69 / 71 CC 8 SCAR 14.8
CC
8
Cov
97%
_from_fcs_string
7.0
_init
2.1
BEGIN
1.0
CRAP 4.4
« Verify/KlondikeTalon.pm ↑ Summary Verify/State/LaxParser.pm »
1 package Games::Solitaire::Verify::Move;
2 20 $Games::Solitaire::Verify::Move::VERSION = '0.2601';
3 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 20 ▶use parent 'Games::Solitaire::Verify::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 20 ▶use Games::Solitaire::Verify::Exception ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 20 __PACKAGE__->mk_acc_ref(
12 [
13 qw(
14 source_type
15 dest_type
16 source
17 dest
18 num_cards
19 _game
20 )
21 ]
22 );
23  
24  
25 sub _from_fcs_string
26 2551 ▶{
Subroutine _from_fcs_string: called CC=7 SCAR=19.5
27 2551 my ( $self, $str ) = @_;
28  
29 2551 ▶ if ( $str =~ m{\AMove a card from stack ([0-9]+) to the foundations\z} )
Branch: 6 branches
BranchTrueFalseTotal
if ($str =~ /\AMove a card from stack ([0-9]+) to the foundations\z/) { } 659 1892 2551
elsif ($str =~ /\AMove a card from freecell ([0-9]+) to the foundations\z/) { } 116 1776 1892
elsif ($str =~ /\AMove a card from freecell ([0-9]+) to stack ([0-9]+)\z/) { } 475 1301 1776
elsif ($str =~ /\AMove a card from stack ([0-9]+) to freecell ([0-9]+)\z/) { } 591 710 1301
elsif ($str =~ /\AMove ([0-9]+) cards from stack ([0-9]+) to stack ([0-9]+)\z/) { } 702 8 710
elsif ($str =~ /\AMove the sequence on top of Stack ([0-9]+) to the foundations\z/) { } 7 1 8
30 {
31 659 my $source = $1;
32  
33 659 $self->source_type("stack");
34 659 $self->dest_type("foundation");
35  
36 659 $self->source($source);
37 }
38 elsif (
39 $str =~ m{\AMove a card from freecell ([0-9]+) to the foundations\z} )
40 {
41 116 my $source = $1;
42  
43 116 $self->source_type("freecell");
44 116 $self->dest_type("foundation");
45  
46 116 $self->source($source);
47 }
48 elsif (
49 $str =~ m{\AMove a card from freecell ([0-9]+) to stack ([0-9]+)\z} )
50 {
51 475 my ( $source, $dest ) = ( $1, $2 );
52  
53 475 $self->source_type("freecell");
54 475 $self->dest_type("stack");
55  
56 475 $self->source($source);
57 475 $self->dest($dest);
58 }
59 elsif (
60 $str =~ m{\AMove a card from stack ([0-9]+) to freecell ([0-9]+)\z} )
61 {
62 591 my ( $source, $dest ) = ( $1, $2 );
63  
64 591 $self->source_type("stack");
65 591 $self->dest_type("freecell");
66  
67 591 $self->source($source);
68 591 $self->dest($dest);
69 }
70 elsif ( $str =~
71 m{\AMove ([0-9]+) cards from stack ([0-9]+) to stack ([0-9]+)\z} )
72 {
73 702 my ( $num_cards, $source, $dest ) = ( $1, $2, $3 );
74  
75 702 $self->source_type("stack");
76 702 $self->dest_type("stack");
77  
78 702 $self->source($source);
79 702 $self->dest($dest);
80 702 $self->num_cards($num_cards);
81 }
82 elsif ( $str =~
83 m{\AMove the sequence on top of Stack ([0-9]+) to the foundations\z} )
84 {
85 7 my $source = $1;
86  
87 7 $self->source_type("stack_seq");
88 7 $self->dest_type("foundation");
89  
90 7 $self->source($source);
91 }
92 else
93 {
94 1 Games::Solitaire::Verify::Exception::Parse::FCS->throw(
95 error => "Cannot parse 'FCS' String", );
96 }
97 }
98  
99 sub _init
100 2551 ▶{
Subroutine _init: called CC=2 SCAR=7.4
101 2551 my ( $self, $args ) = @_;
102  
103 2551 $self->_game( $args->{game} );
104  
105 2551 ▶ if ( exists( $args->{fcs_string} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"fcs_string"}) 2551 0 2551
106 {
107 2551 return $self->_from_fcs_string( $args->{fcs_string} );
108 }
109 0 return ();
110 }
111  
112  
113 20 1; # End of Games::Solitaire::Verify::Move
114  
115 __END__
« Verify/KlondikeTalon.pm ↑ Summary Verify/State/LaxParser.pm »