### ----------------------------------------------------
### -- ReverseIterables
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/01-basic.rakutest
### ----------------------------------------------------
use Test;

use ReverseIterables;

plan 11;

my $iterator = ReverseIterables.new;
is $iterator.pull-one, IterationEnd, 'no iterables';

my @a = ^5;
$iterator = ReverseIterables.new(@a, @a);
is-deeply $iterator.pull-one, 4, 'do we get a good first value';
my @b;
@b.push($iterator.pull-one) for ^9;
is-deeply @b, [3,2,1,0,4,3,2,1,0], 'did we get all values?';
is $iterator.pull-one, IterationEnd, 'at the end now';

is ReverseIterables.new(@a, @a).push-all(my @c),
  IterationEnd,
  'did push-all return IterationEnd';
is-deeply @c, [4,3,2,1,0,4,3,2,1,0], 'did push-all work';

my @d = ReverseIterables.new(@a, @a).Seq;
is-deeply @d, [4,3,2,1,0,4,3,2,1,0], 'did we get all values with .Seq?';

$iterator = ReverseIterables.new(^5, ^5);
is-deeply $iterator.pull-one, 4, 'do we get a good first value';
my @e;
@e.push($iterator.pull-one) for ^9;
is-deeply @e, [3,2,1,0,4,3,2,1,0], 'did we get all values?';
is $iterator.pull-one, IterationEnd, 'at the end now';

my @f = ReverseIterables.new(^5, ^5).Seq;
is-deeply @f, [4,3,2,1,0,4,3,2,1,0], 'did we get all values with .Seq?';

# vim: expandtab shiftwidth=4


