AnyEvent-ForkObject

 view release on metacpan or  search on metacpan

t/01_fo.t  view on Meta::CPAN

            cb      => sub {
                my ($s, $o) = @_;
                $phase++;
                ok $s eq 'ok', 'File::Spec->catfile has done';
                ok $o eq '/etc/passwd', 'File::Spec->catfile works properly';
            }
        );
    });


    my $timer = AE::timer 0.01, 0.01 => sub {
        return if $phase < 5;
        undef $obj; $cv->send
    };

    my $timeout; $timeout =
        AE::timer 2, 0 => sub { undef $obj; undef $timeout; $cv->send  };

    $cv->recv;

    ok $timeout, "Timeout wasn't reached";
}

{
    my $cv = condvar AnyEvent;
    my $obj = new AnyEvent::ForkObject;

t/01_fo.t  view on Meta::CPAN


                $o->Dump(0, sub {
                    my ($st, $ob) = @_;
                    ok $st eq 'fatal', 'Object has been destroyed';
                    ok $ob =~ /destroyed/, 'Fatal message is right';

                });
            });
    });

    my $timer = AE::timer 1, 0 => sub {  $cv->send };

    $cv->recv;
}

{
    my $cv = condvar AnyEvent;
    my $obj = new AnyEvent::ForkObject;
    my $obj2 = new AnyEvent::ForkObject;

    ok $obj, "Constructor";

    kill KILL => $obj->{pid};
    waitpid $obj->{pid}, 0;
    $obj->do(require => 'Data::Dumper', cb => sub {
        diag explain \@_ unless  ok $_[0] eq 'fatal', 'Child was killed';
        my $t;
        $t = AE::timer 0.3, 0 => sub {
            undef $t;
            $cv->send;
        }
    });

    my $dont_call_if_destroyed = 1;
    $obj2->do(require => 'Data::Dumper', cb => sub {
        diag explain \@_;
        $dont_call_if_destroyed = 0;
    });
    kill KILL => $obj2->{pid};
    undef $obj2;

    my $timeout; $timeout = AE::timer 1, 0 => sub { undef $timeout; $cv->send };

    $cv->recv;

    ok $dont_call_if_destroyed, "Don't touch callbacks if destroyed";
    ok $timeout, "Timeout wasn't reached";
}


package FO_Test;

t/01_fo.t  view on Meta::CPAN

                                my ($s, $v) = @_;
                                ok $s eq 'ok' && $v == 456, "FO_Test2->val";
                            });
                        });

                    });
                });
            });
        });

    my $timer = AE::timer 0.5, 0 => sub {  $cv->send };

    $cv->recv;
}

t/02_dbi.t  view on Meta::CPAN

                my ($s, $row) = @_;
                $ok = 0 unless $s eq 'ok';
                $ok = 0 unless 'HASH' eq ref $row;
                $ok = 0 unless $row->{id} == $index + 1;

                if ($last) {
                    ok $ok, 'All data fetched';
                    undef $sth;
                    undef $dbh;
                    my $t;
                    $t = AE::timer 0.5, 0 => sub {
                        undef $t;
                        $cv->send;
                    }
                }
            });

        };

    });
});



( run in 0.469 second using v1.01-cache-2.11-cpan-49f99fa48dc )