test more complex stream
[scpubgit/DKit.git] / lib / DX / ResultStream.pm
index aa54025..6bf251f 100644 (file)
@@ -13,15 +13,28 @@ sub next {
   return if $self->is_exhausted;
   my $start_state = do {
     if (my $cur = $self->_current_state) {
-      $cur->backtrack;
+      $cur->push_backtrack;
     } else {
       $self->for_state
     }
   };
   my $state = $self->_current_state($start_state->run);
+  unless ($state) {
+    $self->_set_is_exhausted(1);
+    return;
+  }
   return +{
     map +($_ => $state->scope_var($_)->bound_value), keys %{$state->scope}
   };
 }
 
+sub results {
+  my ($self) = @_;
+  my @all;
+  while (my $next = $self->next) {
+    push @all, $next;
+  }
+  return @all;
+}
+
 1;