File Coverage

blib/lib/WordList/Test/Dynamic/OneTwo_FirstNextReset.pm
Criterion Covered Total %
statement 21 21 100.0
branch 5 6 83.3
condition n/a
subroutine 6 6 100.0
pod 3 3 100.0
total 35 36 97.2


line stmt bran cond sub pod time code
1             package WordList::Test::Dynamic::OneTwo_FirstNextReset;
2              
3 1     1   2261 use strict;
  1         2  
  1         32  
4              
5 1     1   5 use WordList;
  1         2  
  1         37  
6             our @ISA = qw(WordList);
7              
8 1     1   6 use Role::Tiny::With;
  1         2  
  1         282  
9             with 'WordListRole::EachFromFirstNextReset';
10              
11             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
12             our $DATE = '2021-09-26'; # DATE
13             our $DIST = 'WordList'; # DIST
14             our $VERSION = '0.7.11'; # VERSION
15              
16             our $DYNAMIC = 1;
17              
18             sub reset_iterator {
19 22     22 1 36 my $self = shift;
20 22         43 $self->{_iterator_idx} = 0;
21             }
22              
23             sub first_word {
24 11     11 1 2490 my $self = shift;
25 11         36 $self->reset_iterator;
26 11         20 $self->next_word;
27             }
28              
29             sub next_word {
30 29     29 1 42 my $self = shift;
31 29 50       67 $self->{_iterator_idx} = 0 unless defined $self->{_iterator_idx};
32              
33 29         44 $self->{_iterator_idx}++;
34 29 100       66 if ($self->{_iterator_idx} == 1) { return "one" }
  12 100       31  
35 9         24 elsif ($self->{_iterator_idx} == 2) { return "two" }
36 8         20 else { return undef } ## no critic: Subroutines::ProhibitExplicitReturnUndef
37             }
38              
39             our %STATS = ("avg_word_len",3,"num_words_contain_whitespace",0,"longest_word_len",3,"num_words",2,"num_words_contain_nonword_chars",0,"num_words_contain_unicode",0,"num_words_contains_whitespace",0,"num_words_contains_nonword_chars",0,"shortest_word_len",3,"num_words_contains_unicode",0); # STATS
40              
41             1;
42             # ABSTRACT: Wordlist that returns one, two (via implementing first_word(), next_word(), and reset_iterator())
43              
44             __END__