perl -Ilib t/05_mce_child.t ... ok 2 - spawning asynchronously ok 3 - check for unique pids ok 4 - check list_running ok 5 - check list_joinable ok 6 - check list ok 7 - check pending ok 8 - check is_running child1 ok 9 - check is_joinable child1 ok 10 - check is_running child2 ok 11 - check is_joinable child2 ok 12 - check is_running child3 ok 13 - check is_joinable child3 ... #### { my ( $cnt, @list, %pids, %ret ); local $_; my ( $come_then_i_pray ) = ( "さあ、私は祈る" . "Ǣ" ); ok( 1, "spawning asynchronously" ); # test 2 MCE::Child->create( sub { sleep 1; sleep 1; "$come_then_i_pray $_" } ) for ( 1..3 ); %pids = map { $_ => undef } MCE::Child->list_pids; is ( scalar( keys %pids ), 3, 'check for unique pids' ); # test 3 @list = MCE::Child->list_running; is ( scalar @list, 3, 'check list_running' ); # test 4 @list = MCE::Child->list_joinable; is ( scalar @list, 0, 'check list_joinable' ); # test 5 @list = MCE::Child->list; is ( scalar @list, 3, 'check list' ); # test 6 is ( MCE::Child->pending, 3, 'check pending' ); # test 7 $cnt = 0; for ( @list ) { ++$cnt; is ( $_->is_running, 1, 'check is_running child'.$cnt ); # tests 8, 10, 12 is ( $_->is_joinable, '', 'check is_joinable child'.$cnt ); # tests 9, 11, 13 } $cnt = 0; for ( @list ) { ++$cnt; $ret{ $_->join } = 1; is ( $_->error, undef, 'check error child'.$cnt ); } is ( scalar keys %ret, 3, 'check for unique values' ); for ( sort keys %ret ) { my $id = chop; s/ $//; is ( $_, $come_then_i_pray, "check for utf8 string $id" ); }; }