<commit_before>#!./parrot
# Copyright (C) 2010, Parrot Foundation.

=head1 NAME

t/pmc/socket_ipv6.t - tests for the Socket PMC that require IPv6

=head1 SYNOPSIS

    % prove t/pmc/socket_ipv6.t

=head1 DESCRIPTION

IPv6-related tests for the Socket PMC.

=cut

.include 'socket.pasm'
.include 'iglobals.pasm'
.include 'errors.pasm'



.sub main :main
    .include 'test_more.pir'

    plan(16)

    check_for_ipv6()

    test_tcp_socket6()
    test_udp_socket6()

    test_bind()

    test_server()
.end

.sub test_bind
    .local pmc sock, addrinfo
    .local string str, null_string
    .local int result

    sock = new 'Socket'
    sock.'socket'(.PIO_PF_INET6, .PIO_SOCK_STREAM, .PIO_PROTO_TCP)
    addrinfo = sock.'getaddrinfo'(null_string, 1234, .PIO_PROTO_TCP, .PIO_PF_INET6, 0)
    sock.'bind'(addrinfo)

    str = sock.'local_address'()
    is(str, "::1:1234", "local address of bound socket is ::1")

    sock.'close'()

    sock.'socket'(.PIO_PF_INET, .PIO_SOCK_STREAM, .PIO_PROTO_TCP)
    addrinfo = sock.'getaddrinfo'(null_string, 1234, .PIO_PROTO_TCP, .PIO_PF_INET, 0)
    sock.'bind'(addrinfo)

    str = sock.'local_address'()<commit_msg>Fix IPv6 test count<commit_after>#!./parrot
# Copyright (C) 2010, Parrot Foundation.

=head1 NAME

t/pmc/socket_ipv6.t - tests for the Socket PMC that require IPv6

=head1 SYNOPSIS

    % prove t/pmc/socket_ipv6.t

=head1 DESCRIPTION

IPv6-related tests for the Socket PMC.

=cut

.include 'socket.pasm'
.include 'iglobals.pasm'
.include 'errors.pasm'



.sub main :main
    .include 'test_more.pir'

    plan(11)

    check_for_ipv6()

    test_tcp_socket6()
    test_udp_socket6()

    test_bind()

    test_server()
.end

.sub test_bind
    .local pmc sock, addrinfo
    .local string str, null_string
    .local int result

    sock = new 'Socket'
    sock.'socket'(.PIO_PF_INET6, .PIO_SOCK_STREAM, .PIO_PROTO_TCP)
    addrinfo = sock.'getaddrinfo'(null_string, 1234, .PIO_PROTO_TCP, .PIO_PF_INET6, 0)
    sock.'bind'(addrinfo)

    str = sock.'local_address'()
    is(str, "::1:1234", "local address of bound socket is ::1")

    sock.'close'()

    sock.'socket'(.PIO_PF_INET, .PIO_SOCK_STREAM, .PIO_PROTO_TCP)
    addrinfo = sock.'getaddrinfo'(null_string, 1234, .PIO_PROTO_TCP, .PIO_PF_INET, 0)
    sock.'bind'(addrinfo)

    str = sock.'local_address'()
{'fraction_non_alphanumeric': 0.12942191544434858, 'fraction_numerical': 0.029767040552200173, 'mean_word_length': 3.4255725190839694, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3264065', 'n_tokens_mistral': 962, 'n_tokens_neox': 912, 'n_words': 198}