1#!/usr/bin/perl; 2use strict; 3use warnings; 4 5use Test::More 0.88; 6our $CLASS = 'Child'; 7require_ok( $CLASS ); 8 9my @children = map { $CLASS->new(sub { 1 }) } 1 .. 4; 10my @get = $CLASS->all_procs; 11is( @get, 0, "0 children started" ); 12 13my @all; 14push @all => $_->start for @children; 15 16@get = $CLASS->all_procs; 17is( @get, 4, "4 children" ); 18is_deeply( \@get, \@all, "Exact list" ); 19 20is_deeply( 21 [ $CLASS->all_proc_pids ], 22 [ map { $_->pid } @all ], 23 "pids" 24); 25 26is( $_->exit(), undef, "Not waited " . $_->pid ) for @all; 27$CLASS->wait_all(); 28ok( defined($_->exit()), "waited " . $_->pid ) for @all; 29 30done_testing; 31