File: 06_socket.t

package info (click to toggle)
libanyevent-perl 7.010-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,528 kB
  • sloc: perl: 6,349; sh: 108; makefile: 10
file content (39 lines) | stat: -rw-r--r-- 1,014 bytes parent folder | download | duplicates (6)
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
34
35
36
37
38
39
$| = 1; print "1..19\n";

no warnings; # nazis

use AnyEvent::Socket;

print "ok 1\n";

sub ph {
   my ($id, $str, $dport, $host, $port) = @_;

   $str =~ s/_/ /g unless ref $str;

   my ($h, $p) = parse_hostport ref $str ? $$str : $str, $dport;

   print $h eq $host && $p eq $port ? "" : "not ", "ok $id # '$str,$dport' => '$h,$p' eq '$host,$port'\n";
}

ph  2, "";
ph  3, "localhost";
ph  4, qw(localhost 443 localhost 443);
ph  5, qw(localhost:444 443 localhost 444);
ph  6, qw(10.0.0.1 443 10.0.0.1 443);
ph  7, qw(10.1:80 443 10.1 80);
ph  8, qw(::1 443 ::1 443);
ph  9, qw(::1:80 443 ::1:80 443);
ph 10, qw([::1]:80 443 ::1 80);
ph 11, qw([::1]_80 443 ::1 80);
ph 12, qw([::1]_: 443);
ph 13, qw([::1]: 443);
ph 14, qw(::1_smtp 443 ::1 smtp);
ph 15, qw([www.linux.org]_80 443 www.linux.org 80);
ph 16, qw([10.1]:80 443 10.1 80);
ph 17, qw(10.1_80 443 10.1 80);

my $var = "2002:58c6:438b::10.0.0.17";
ph 18, \$var, qw(443 2002:58c6:438b::10.0.0.17 443);
ph 19, \$var, qw(443 2002:58c6:438b::10.0.0.17 443);