File Coverage

blib/lib/Gherkin/ParserContext.pm
Criterion Covered Total %
statement 21 27 77.7
branch n/a
condition 3 7 42.8
subroutine 7 9 77.7
pod 0 5 0.0
total 31 48 64.5


line stmt bran cond sub pod time code
1             package Gherkin::ParserContext;
2             $Gherkin::ParserContext::VERSION = '41.0.0';
3 1     1   5 use strict;
  1         1  
  1         28  
4 1     1   3 use warnings;
  1         1  
  1         57  
5              
6 1     1   6 use List::Util qw( uniq );
  1         2  
  1         74  
7              
8 1         16 use Class::XSAccessor accessors =>
9 1     1   3 [ qw/token_scanner token_matcher token_queue _errors/, ];
  1         2  
10              
11             sub new {
12 3     3 0 5 my ( $class, $options ) = @_;
13 3   50     12 $options->{'token_queue'} ||= [];
14 3   50     11 $options->{'_errors'} ||= [];
15 3         6 bless $options, $class;
16             }
17              
18 0     0 0 0 sub add_tokens { my $self = shift; push( @{ $self->token_queue }, @_ ); }
  0         0  
  0         0  
19 3     3 0 5 sub errors { my $self = shift; return @{ $self->_errors } }
  3         3  
  3         11  
20             sub add_errors {
21 0     0 0 0 my $self = shift;
22 0         0 push @{ $self->{'_errors'} }, @_;
  0         0  
23             }
24              
25             sub read_token {
26 36     36 0 40 my ($self) = shift();
27 36   33     46 return shift( @{ $self->token_queue } ) || $self->token_scanner->read;
28             }
29              
30             1;