3 use aliased 'DX::Op::FromCode';
4 use aliased 'DX::ArrayStream';
18 my @shells = qw(csh bash);
21 bash => { map +($_ => 1),
22 qw(joe.example.com kitty.scsys.co.uk pryde.scsys.co.uk) },
23 csh => { map +($_ => 1),
24 qw(jim.example.com joe.example.com bob.example.com) },
28 my ($var, $array) = @_;
30 my ($self, $state) = @_;
31 $state->bind_stream_then(
32 $state->scope_var($var),
33 ArrayStream->from_array(@$array),
39 my $op = FromCode->new(
40 code => bind_array(S => \@servers),
41 next => FromCode->new(
43 my ($self, $state) = @_;
44 my $server = $state->scope_var('S')->bound_value;
45 if ($server =~ /\.example\.com$/) {
46 return $state->then($self->next);
48 return $state->backtrack;
53 my %scope = map +($_ => $_), qw(S);
54 my %by_id = map +($_ => DX::Var->new(id => $_)), qw(S);
56 my $state = DX::State->new(
64 my $stream = DX::ResultStream->new(for_state => $state);
66 is($stream->next->{'S'}, $_)
67 for qw(jim.example.com joe.example.com bob.example.com);
69 dies_ok { $stream->next } 'No more';