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 = '39.0.0';
3 1     1   6 use strict;
  1         1  
  1         51  
4 1     1   5 use warnings;
  1         2  
  1         49  
5              
6 1     1   5 use List::Util qw( uniq );
  1         2  
  1         72  
7              
8 1         18 use Class::XSAccessor accessors =>
9 1     1   4 [ qw/token_scanner token_matcher token_queue _errors/, ];
  1         2  
10              
11             sub new {
12 3     3 0 10 my ( $class, $options ) = @_;
13 3   50     23 $options->{'token_queue'} ||= [];
14 3   50     37 $options->{'_errors'} ||= [];
15 3         12 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 8 sub errors { my $self = shift; return @{ $self->_errors } }
  3         6  
  3         22  
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 99 my ($self) = shift();
27 36   33     52 return shift( @{ $self->token_queue } ) || $self->token_scanner->read;
28             }
29              
30             1;