Upgrade to Test::Harness 3.05
[p5sagit/p5-mst-13.2.git] / lib / TAP / Parser / Iterator / Array.pm
1 package TAP::Parser::Iterator::Array;
2
3 use strict;
4 use TAP::Parser::Iterator ();
5 use vars qw($VERSION @ISA);
6 @ISA = 'TAP::Parser::Iterator';
7
8 =head1 NAME
9
10 TAP::Parser::Iterator::Array - Internal TAP::Parser Iterator
11
12 =head1 VERSION
13
14 Version 3.05
15
16 =cut
17
18 $VERSION = '3.05';
19
20 =head1 SYNOPSIS
21
22   use TAP::Parser::Iterator::Array;
23   my $it = TAP::Parser::Iterator->new(\@array);
24
25   my $line = $it->next;
26
27 Originally ripped off from L<Test::Harness>.
28
29 =head1 DESCRIPTION
30
31 B<FOR INTERNAL USE ONLY!>
32
33 This is a simple iterator wrapper for arrays.
34
35 =head2 Class Methods
36
37 =head3 C<new>
38
39 Create an iterator.
40
41 =head2 Instance Methods
42
43 =head3 C<next>
44
45 Iterate through it, of course.
46
47 =head3 C<next_raw>
48
49 Iterate raw input without applying any fixes for quirky input syntax.
50
51 =head3 C<wait>
52
53 Get the wait status for this iterator. For an array iterator this will always
54 be zero.
55
56 =head3 C<exit>
57
58 Get the exit status for this iterator. For an array iterator this will always
59 be zero.
60
61 =cut
62
63 sub new {
64     my ( $class, $thing ) = @_;
65     chomp @$thing;
66     bless {
67         idx   => 0,
68         array => $thing,
69         exit  => undef,
70     }, $class;
71 }
72
73 sub wait { shift->exit }
74
75 sub exit {
76     my $self = shift;
77     return 0 if $self->{idx} >= @{ $self->{array} };
78     return;
79 }
80
81 sub next_raw {
82     my $self = shift;
83     return $self->{array}->[ $self->{idx}++ ];
84 }
85
86 1;