Skip to content

Commit

Permalink
get_bool on a Socket returns whether the Socket is open. The is_close…
Browse files Browse the repository at this point in the history
…d method returns the opposite value. Tests for creating a new socket shouldn't use the get_bool vtable, since that shows whether the socket was opened, which these tests aren't doing
  • Loading branch information
Whiteknight committed Jan 4, 2011
1 parent 581131f commit 7295dd1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/pmc/socket.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ Test if the socket is closed.
*/

METHOD is_closed() {
const INTVAL status = VTABLE_get_bool(INTERP, SELF);
const INTVAL status = !VTABLE_get_bool(INTERP, SELF);
RETURN(INTVAL status);
}

Expand Down
22 changes: 11 additions & 11 deletions t/pmc/socket.t
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Tests the Socket PMC.
.sub test_get_fd
new $P0, ['Socket']
$N0 = $P0.'get_fd'()
isnt($N0, -1, 'Socket get_fd did not return -1')
ok(1, "can get_fd a Socket")
.end

.sub test_read
Expand All @@ -68,7 +68,7 @@ Tests the Socket PMC.

.sub test_bool
new $P0, ['Socket']
ok($P0, 'get_bool on Socket')
nok($P0, 'get_bool on closed Socket')
.end

.sub test_close
Expand All @@ -94,7 +94,7 @@ Tests the Socket PMC.

$S0 = typeof $P2
$S1 = 'Socket'
diag($S0)

$I0 = iseq $S0, $S1
ok($I0, 'Cloned PMC has correct type TT#1820')
.end
Expand All @@ -103,60 +103,60 @@ Tests the Socket PMC.
.local pmc sock
sock = new 'Socket'
sock.'socket'(.PIO_PF_INET, .PIO_SOCK_STREAM, .PIO_PROTO_TCP)
ok(sock, 'Created a TCP Socket')
ok(1, 'Created a TCP Socket')
.end

.sub test_tcp_socket6
.local pmc sock
sock = new 'Socket'
sock.'socket'(.PIO_PF_INET6, .PIO_SOCK_STREAM, .PIO_PROTO_TCP)
ok(sock, 'Created a IPv6 TCP Socket')
ok(1, 'Created a IPv6 TCP Socket')
.end

.sub test_raw_tcp_socket6
.local pmc sock
sock = new 'Socket'
sock.'socket'(.PIO_PF_INET6, .PIO_SOCK_RAW, .PIO_PROTO_TCP)
ok(sock, 'Created a raw IPv6 TCP Socket')
ok(1, 'Created a raw IPv6 TCP Socket')
.end

.sub test_udp_socket6
.local pmc sock
sock = new 'Socket'

sock.'socket'(.PIO_PF_INET6, .PIO_SOCK_STREAM, .PIO_PROTO_UDP)
ok(sock, 'Created a IPv6 UDP Socket')
ok(1, 'Created a IPv6 UDP Socket')
.end

.sub test_raw_udp_socket6
.local pmc sock
sock = new 'Socket'

sock.'socket'(.PIO_PF_INET6, .PIO_SOCK_RAW, .PIO_PROTO_UDP)
ok(sock, 'Created a raw IPv6 UDP Socket')
ok(1, 'Created a raw IPv6 UDP Socket')
.end

.sub test_raw_tcp_socket
.local pmc sock
sock = new 'Socket'
sock.'socket'(.PIO_PF_INET, .PIO_SOCK_RAW, .PIO_PROTO_TCP)
ok(sock, 'Created a raw TCP Socket')
ok(1, 'Created a raw TCP Socket')
.end

.sub test_udp_socket
.local pmc sock
sock = new 'Socket'

sock.'socket'(.PIO_PF_INET, .PIO_SOCK_STREAM, .PIO_PROTO_UDP)
ok(sock, 'Created a UDP Socket')
ok(1, 'Created a UDP Socket')
.end

.sub test_raw_udp_socket
.local pmc sock
sock = new 'Socket'

sock.'socket'(.PIO_PF_INET, .PIO_SOCK_RAW, .PIO_PROTO_UDP)
ok(sock, 'Created a raw UDP Socket')
ok(1, 'Created a raw UDP Socket')
.end

# Local Variables:
Expand Down

0 comments on commit 7295dd1

Please sign in to comment.