From: Matt S Trout Date: Mon, 20 Jan 2014 11:29:48 +0000 (+0000) Subject: test more complex stream X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=scpubgit%2FDKit.git;a=commitdiff_plain;h=26300a7d3e2d9e07989735682ccd96209d8968bf test more complex stream --- diff --git a/lib/DX/ResultStream.pm b/lib/DX/ResultStream.pm index 28555a9..6bf251f 100644 --- a/lib/DX/ResultStream.pm +++ b/lib/DX/ResultStream.pm @@ -28,4 +28,13 @@ sub next { }; } +sub results { + my ($self) = @_; + my @all; + while (my $next = $self->next) { + push @all, $next; + } + return @all; +} + 1; diff --git a/t/basic.t b/t/basic.t index 3bd0684..1655c85 100644 --- a/t/basic.t +++ b/t/basic.t @@ -77,8 +77,6 @@ is($stream->next->{'S'}, $_) is($stream->next, undef, 'No more'); -exit 0; - my $complex_op = FromCode->new( code => bind_array(S => \@servers), next => FromCode->new( @@ -96,10 +94,15 @@ my $cstream = DX::ResultStream->new( for_state => make_state([ qw(S P) ], $complex_op) ); -::Dwarn($cstream->next); -::Dwarn($cstream->next); -::Dwarn($cstream->next); -::Dwarn($cstream->next); -::Dwarn($cstream->next); +is_deeply( + [ $cstream->results ], + [ + { P => 'csh', S => 'jim.example.com' }, + { P => 'csh', S => 'joe.example.com' }, + { P => 'bash', S => 'joe.example.com' }, + { P => 'csh', S => 'bob.example.com' }, + ], + 'Complex stream' +); done_testing;