remove the _then bind methods
[scpubgit/DKit.git] / t / basic.t
index be3e32d..8612ea7 100644 (file)
--- a/t/basic.t
+++ b/t/basic.t
@@ -28,10 +28,9 @@ sub bind_array {
   my ($var, $array) = @_;
   sub {
     my ($self, $state) = @_;
-    $state->bind_stream_then(
+    $state->then($self->next)->bind_stream(
       $state->scope_var($var),
       ArrayStream->from_array(@$array),
-      $self->next
     )
   }
 }
@@ -78,7 +77,7 @@ sub make_state {
 
 my $stream = DX::ResultStream->new(for_state => make_state([ 'S' ], $op));
 
-is($stream->next->{'S'}, $_)
+is($stream->next->value_for('S'), $_)
   for qw(jim.example.com joe.example.com bob.example.com);
 
 is($stream->next, undef, 'No more');
@@ -96,12 +95,21 @@ my $complex_op = FromCode->new(
   )
 );
 
+sub bound_values {
+  map {
+    my $v = $_;
+    +{
+       map +($_ => $v->value_for($_)), $v->var_names,
+    }
+  } @_
+}
+
 my $cstream = DX::ResultStream->new(
   for_state => make_state([ qw(S P) ], $complex_op)
 );
 
 is_deeply(
-  [ $cstream->results ],
+  [ bound_values $cstream->results ],
   [
     { P => 'csh', S => 'jim.example.com' },
     { P => 'csh', S => 'joe.example.com' },
@@ -141,7 +149,7 @@ my $callstream = DX::ResultStream->new(
 );
 
 is_deeply(
-  [ $callstream->results ],
+  [ bound_values $callstream->results ],
   [
     { P => 'csh', S => 'jim.example.com' },
     { P => 'csh', S => 'joe.example.com' },
@@ -182,7 +190,7 @@ my $orstream = DX::ResultStream->new(
 );
 
 is_deeply(
-  [ $orstream->results ],
+  [ bound_values $orstream->results ],
   [
     {
       S => "kitty.scsys.co.uk"
@@ -218,7 +226,7 @@ my $orstream_2 = DX::ResultStream->new(
 );
 
 is_deeply(
-  [ $orstream_2->results ],
+  [ bound_values $orstream_2->results ],
   [
     {
       S => "jim.example.com"