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