File: 140_yahc_loop.t

package info (click to toggle)
libyahc-perl 0.035-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 440 kB
  • sloc: perl: 3,661; makefile: 2
file content (33 lines) | stat: -rw-r--r-- 584 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env perl

use strict;
use warnings;

use EV;

use YAHC;
use Test::More;
use Time::HiRes qw/time/;
use Scalar::Util qw/weaken/;

my $loop = EV::default_loop();
my ($yahc, $yahc_storage) = YAHC->new({ loop => $loop });

my $called = 0;

my $weakloop = $loop;
weaken($weakloop);
my $c1 = $yahc->request({
    host => [ "localhost:1000" ],
    callback => sub {
        $called++;
        $weakloop->break;
    },
});

my $iterations = 0;
$loop->run(EV::RUN_ONCE) until $called || $iterations++ > 1000;

is($called, 1, "Running the default eventloop ran YAHC");

done_testing;