Async-Event-Interval

 view release on metacpan or  search on metacpan

t/05-base.t  view on Meta::CPAN

use strict;
use warnings;

use lib 't/lib';
use TestHelper;
use Test::More;

use Async::Event::Interval;

my $mod = 'Async::Event::Interval';

my $file = 't/test.data';

{
    my $e = $mod->new(0.2, \&perform, 10);

    $e->start;

    is -e $file, undef, "event is asynchronious";

    sleep 2;

    $e->stop;

    my $data;

    {
        local $/;
        open my $fh, '<', $file or die $!;
        $data = <$fh>;
    }

    is $data, 10, "single event does the right thing";

    unlink $file or die $!;
    is -e $file, undef, "temp file removed ok";
}

sub perform {
    my $arg = shift;
    sleep 1;
    open my $wfh, '>', $file or die $!;
    print $wfh $arg;
    close $wfh;
}



( run in 0.793 second using v1.01-cache-2.11-cpan-9581c071862 )