### ----------------------------------------------------
### -- ParaSeq
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: xt/01-chaining.rakutest
### ----------------------------------------------------
use Test;
use paths;
use path-utils;
use ParaSeq;

plan 10;

my uint $head = 1000;

sub is-Para($seq, str $tag) is test-assertion {
    subtest "$tag: check ParaSeq" => {
        plan 3;
        isa-ok $seq, ParaSeq;
        is $seq.stats.elems, 0, "$tag: nothing happened yet";
        is-deeply $seq.auto, True, 'auto is set';
    }
}

my $seq1 = paths($*PROGRAM.parent(2).add("t")).&hyperize;
is-Para($seq1, 'hyperize');

my $seq2 = $seq1.map({ ($_ xx 100).Slip });
is-Para($seq1, 'xx 100');

my $seq3 = $seq2.sort;
is-Para($seq3, 'sort');

my $seq4 = $seq3.grep(&path-is-text);
is-Para($seq4, 'grep(is-text)');

my $seq5 = $seq4.map(*.IO.lines.Slip);
is-Para($seq5, 'lines');

my $seq6 = $seq5.pairs;
is-Para($seq6, 'pairs');

my $seq7 = $seq6.grep(*.value.contains("expandtab"));
is-Para($seq7, 'grep(expandtab)');

my $seq8 = $seq7.head($head);
is-Para($seq8, "head($head)");

my @result := $seq8.List;
isa-ok @result.are, Pair, 'All pairs';
is @result.elems, $head, 'Did we get all the expected results';

#for $seq1, $seq2, $seq3, $seq4, $seq5, $seq6, $seq7, $seq8 -> $seq is raw {
#    say $seq.VAR.name;
#    say "processed: $seq.processed(), produced: $seq.produced()";
#    .say for $seq.stats.tail(20);
#}

# vim: expandtab shiftwidth=4


