Async-Simple-Pool
view release on metacpan or search on metacpan
t/07-pool-inits.t view on Meta::CPAN
#!perl -T
use Modern::Perl;
use POSIX;
use Test::Spec;
use Test::Exception;
use Time::HiRes qw/ sleep time /;
plan tests => 37;
my $dev_mode = 0;
# use lib '../lib';
use Data::Dumper;
use Async::Simple::Pool;
warn 'DEVELOPER MODE' if $dev_mode;
my $timeout = $dev_mode ? 0.03 : 0.5;
my $full_cycle_worst_time = 3 * $timeout * 10 * 1.5;
my $worker_delay = $timeout * 10;
my $is_win = $^O =~ /^(dos|os2|MSWin32|NetWare)$/;
describe 'All' => sub {
describe 'init' => sub {
# Create a fork process, which will wait for data and execute &$sub if data will be passed
my $pool;
ok $pool = Async::Simple::Pool->new( ), 'all params are optional';
isa_ok( $pool, 'Async::Simple::Pool', 'successful init' );
};
describe 'process' => sub {
my( $task, @data );
before each => sub {
$task = sub {
my( $data ) = @_;
$data->{ok} = 1;
return $data;
};
@data = map { \%{{ i => $_ }} } 1..20;
};
it 'default params check at simple start' => sub {
my $pool;
ok( $pool = Async::Simple::Pool->new( $task ), 'simplest pool has been created' );
isa_ok( $pool, 'Async::Simple::Pool' );
isa_ok( $pool->tasks, 'ARRAY', 'task list is list' );
# Defaults
is( $pool->tasks_count, 10, 'default task count' );
is( $pool->flush_data, 0, 'we flush_data by default' );
is( $pool->result_type, 'fulllist', 'default result type' );
( run in 0.723 second using v1.01-cache-2.11-cpan-364913b4093 )