Skip to content

Commit

Permalink
Merge pull request #377 from jstuder-gh/issue_1397_ords_rotor
Browse files Browse the repository at this point in the history
Rakudo Issue 1397: Test Rotor iter stops pulling after IterationEnd
  • Loading branch information
lizmat committed Jan 14, 2018
2 parents c7615b3 + d6dcfbf commit 411b2bf
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion S32-list/rotor.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 15;
plan 16;

#?DOES 1
sub r(\pos, $expected, $descr? is copy, *%named) {
Expand Down Expand Up @@ -57,3 +57,20 @@ is-deeply <a b c d e f>.rotor(1...*),
is-deeply <a b c d e f>.rotor(2 => -2, 1),
(("a", "b"), ("a",), ("b", "c"), ("b",), ("c", "d"), ("c",), ("d", "e"), ("d",), ("e", "f"), ("e",)),
".rotor works as expected with negative gap";

# [Github Issue 1397](https://github.com/rakudo/rakudo/issues/1397)
subtest '.rotor: 2 => -1, :partial obeys Iterator protocol' => {
plan 2;

my $iterends = 0;
my $s := Seq.new: class :: does Iterator {
method pull-one {
return $++ if $++ < 3;
$iterends++;
IterationEnd
}
}.new;
is-deeply $s.rotor(2 => -1, :partial), ((0, 1), (1, 2), (2,)).Seq,
'got right result';
is $iterends, 1, 'stopped pulling after receiving IterationEnd';
}

0 comments on commit 411b2bf

Please sign in to comment.