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

plan 24;

my constant $elems    = 10000;
my constant $list     = (^$elems).pick(*).List;
my constant $batch    = 16;
my constant $unique   = $list.unique.List;
my constant $as       = * div 100;
my constant $hundreds = $list.unique(:$as).List;
my constant $same     = (1 xx $elems).List;
my constant $one      = $same.unique.List;

for 1, ParaSeq.default-degree {
    for &[===], &[==] -> $with {
        my $seq := $list.&hyperize($batch, $_).unique(:$with);
        isa-ok $seq, $_ == 1 ?? Seq !! ParaSeq;
        is-deeply $seq.List, $unique,
          "list.unique with degree = $_ with $with.name()";

        $seq := $list.&hyperize($batch, $_).unique(:$with, :$as);
        isa-ok $seq, $_ == 1 ?? Seq !! ParaSeq;
        is-deeply $seq.List, $hundreds,
          "list.unique(:as(* div 100)) with degree = $_ with $with.name()";

        $seq := $same.&hyperize($batch, $_).unique(:$with);
        isa-ok $seq, $_ == 1 ?? Seq !! ParaSeq;
        is-deeply $seq.List, $one,
          "same.unique with degree = $_ with $with.name()";
    }
}

# vim: expandtab shiftwidth=4


