File Coverage

blib/lib/Games/Solitaire/Verify/LinesIter.pm
Criterion Covered Total %
statement 28 30 93.3
branch 2 4 50.0
condition n/a
subroutine 8 8 100.0
pod 1 1 100.0
total 39 43 90.7


line stmt bran cond sub pod time code
1             package Games::Solitaire::Verify::LinesIter;
2             $Games::Solitaire::Verify::LinesIter::VERSION = '0.2601';
3 4     4   296431 use strict;
  4         10  
  4         177  
4 4     4   25 use warnings;
  4         9  
  4         257  
5 4     4   639 use autodie;
  4         22010  
  4         41  
6              
7             sub new
8             {
9 6     6 1 13 my $class = shift;
10              
11 6         25 my $self = bless {}, $class;
12              
13 6         21 $self->_init(@_);
14              
15 6         13 return $self;
16             }
17              
18             sub _init
19             {
20 6     6   13 my ( $self, $args ) = @_;
21              
22 6         37 $self->{_get} = $args->{_get};
23 6         14 $self->{_line_num} = 0;
24              
25 6         8 return;
26             }
27              
28             sub _get_line
29             {
30 3814     3814   5606 my ( $self, ) = @_;
31              
32 3814         6886 my $ret = $self->{_get}->();
33 3814         20700 return ( $ret, ++$self->{_line_num} );
34             }
35              
36             sub _assert_empty_line
37             {
38 1156     1156   1482 my ( $self, ) = @_;
39              
40 1156         1572 my ( $s, $line_idx ) = $self->_get_line;
41              
42 1156 50       1779 if ( $s ne '' )
43             {
44 0         0 Carp::confess("Line '$line_idx' is not empty, but '$s'");
45             }
46              
47 1156         1676 return;
48             }
49              
50             sub _compare_line
51             {
52 1842     1842   3947 my ( $self, $wanted_line, $title, ) = @_;
53              
54 1842         3662 my ( $line, $line_idx ) = $self->_get_line;
55 1842 50       4524 if ( $line ne $wanted_line )
56             {
57 0         0 Carp::confess(
58             "$title string is '$line' vs. '$wanted_line' at line no. $line_idx"
59             );
60             }
61              
62 1842         4381 return;
63             }
64              
65             1;
66              
67             __END__