### ----------------------------------------------------
### -- ParaSeq
### -- Licenses: Artistic-2.0
### -- Authors: Elizabeth Mattijsen
### -- File: t/07-first.rakutest
### ----------------------------------------------------
use Test;
use ParaSeq;

plan 22;

my constant $elems = 200000;
my constant @list  = (^$elems).reverse.List;

my constant $grepper   = * %% 2;
my constant $first     = @list.first;
my constant $first2    = @list.first($grepper);
my constant $first2e   = @list.first($grepper, :end);
my constant $first2k   = @list.first($grepper, :k);
my constant $first2ke  = @list.first($grepper, :k, :end);
my constant $first2p   = @list.first($grepper, :p);
my constant $first2pe  = @list.first($grepper, :p, :end);
my constant $first2kv  = @list.first($grepper, :kv);
my constant $first2kve = @list.first($grepper, :kv, :end);

my constant $batch = 16;

for 1, ParaSeq.default-degree {
    is-deeply @list.&hyperize($batch, $_).first, $first,
      "first with degree $_";

    is-deeply @list.&hyperize($batch, $_).first($grepper), $first2,
      "first(* %% 2) with degree = $_";
    is-deeply @list.&hyperize($batch, $_).first($grepper, :v), $first2,
      "first(* %% 2, :v) with degree = $_";

    is-deeply @list.&hyperize($batch, $_).first($grepper, :end), $first2e,
      "first(%% * 2, :end) with degree = $_";
    is-deeply @list.&hyperize($batch, $_).first($grepper, :v, :end), $first2e,
      "first(%% * 2, :v, :end) with degree = $_";

    is-deeply @list.&hyperize($batch, $_).first($grepper, :k), $first2k,
      "first(%% * 2, :k) with degree = $_";
    is-deeply @list.&hyperize($batch, $_).first($grepper, :k, :end), $first2ke,
      "first(%% * 2, :k, :end) with degree = $_";

    is-deeply @list.&hyperize($batch, $_).first($grepper, :p), $first2p,
      "first(%% * 2, :p) with degree = $_";
    is-deeply @list.&hyperize($batch, $_).first($grepper, :p, :end), $first2pe,
      "first(%% * 2, :p, :end) with degree = $_";

    is-deeply @list.&hyperize($batch, $_).first($grepper, :kv), $first2kv,
      "first(%% * 2, :kv) with degree = $_";
    is-deeply @list.&hyperize($batch, $_).first($grepper, :kv, :end), $first2kve,
      "first(%% * 2, :kv, :end) with degree = $_";
}

# vim: expandtab shiftwidth=4


