AnyEvent-Net-Curl-Queued
view release on metacpan or search on metacpan
t/01-net-curl-compatibility.t view on Meta::CPAN
#!perl
# shamelessly borrowed from Net::Curl t/compat-19multi.t
use lib qw(inc);
use strict;
use utf8;
use warnings qw(all);
use Test::More;
use Test::HTTP::AnyEvent::Server;
use AnyEvent::Net::Curl::Queued::Easy;
use AnyEvent::Net::Curl::Queued::Multi;
use Net::Curl::Easy qw(:constants);
use Net::Curl::Multi qw(:constants);
my $server = Test::HTTP::AnyEvent::Server->new(forked => 1);
my $url = $server->uri . 'echo/head';
my $last_fdset = '';
my $last_cnt = 0;
my $curl = AnyEvent::Net::Curl::Queued::Easy->new($url);
isa_ok($curl, qw(AnyEvent::Net::Curl::Queued::Easy));
can_ok($curl, qw(init _finish));
$curl->init;
ok($curl->{private} = "foo", "Setting private data");
my $curl2 = AnyEvent::Net::Curl::Queued::Easy->new(initial_url => $url);
isa_ok($curl2, qw(AnyEvent::Net::Curl::Queued::Easy));
can_ok($curl2, qw(init _finish));
$curl2->init;
ok($curl2->{private} = 42, "Setting private data");
my $curlm = AnyEvent::Net::Curl::Queued::Multi->new({ pool => {} });
isa_ok($curlm, qw(AnyEvent::Net::Curl::Queued::Multi));
can_ok($curlm, qw(CURLMOPT_TIMERFUNCTION));
is(
CURL_POLL_IN |
CURL_POLL_OUT,
CURL_POLL_INOUT,
"CURL_POLL_INOUT == CURL_POLL_IN + CURL_POLL_OUT"
);
my @fds = $curlm->fdset;
ok(@fds == 3 && ref($fds[0]) eq '' && ref($fds[1]) eq '' && ref($fds[2]) eq '', "fdset returns 3 vectors");
ok(!$fds[0] && !$fds[1] && !$fds[2], "The three returned vectors are empty");
$curlm->perform;
@fds = $curlm->fdset;
ok(!$fds[0] && !$fds[1] && !$fds[2], "The three returned vectors are still empty after perform");
$curlm->add_handle($curl);
@fds = $curlm->fdset;
ok(!$fds[0] && !$fds[1] && !$fds[2], "The three returned vectors are still empty after perform and add_handle");
$curlm->perform;
@fds = $curlm->fdset;
my $cnt;
$cnt = unpack("%32b*", $fds[0].$fds[1]);
( run in 0.970 second using v1.01-cache-2.11-cpan-39bf76dae61 )