File: 040-batch.t

package info (click to toggle)
libparallel-iterator-perl 1.002-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 184 kB
  • sloc: perl: 520; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 560 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use strict; use warnings;

use Test::More;
use Parallel::Iterator qw( iterate_as_array );

my @spec = (
    { batch    => 97 },
    { batch    => 100 },
    { adaptive => 1 },
    { adaptive => 2 },
    { adaptive => [ 10, 1, 20 ] }
);

plan tests => @spec * 1;

for my $spec ( @spec ) {
    my @in = ( 1 .. 5000 );
    my @want = map { $_ * 2 } @in;

    my @got = iterate_as_array(
        $spec,
        sub {
            my ( $id, $job ) = @_;
            return $job * 2;
        },
        \@in
    );

    is_deeply \@got, \@want, "processed OK";
}

1;