Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote branch 'origin/toqast'
Switches $socket.recv to consistent character semantics
  • Loading branch information
moritz committed Jul 25, 2012
2 parents 42450a0 + 333ca4c commit 89d4c66
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
16 changes: 7 additions & 9 deletions S32-io/IO-Socket-INET.pl
Expand Up @@ -86,8 +86,8 @@
$fd.close();
while my $client = $server.accept() {
# Also sends two 3 byte unicode characters
$client.send(([~] '0'..'9', 'a'..'z')
~ "{chr 0xbeef}{chr 0xbabe}");
$client.send(join '', '0'..'9', 'a'..'z',
chr(0xbeef), chr(0xbabe) );
$client.close();
}
}
Expand All @@ -100,16 +100,14 @@
say $sock.recv(3); # 789
say $sock.recv(26); # a-z
# All is left are the two 3 byte characters
my $beef = $sock.recv(3);
my $beef = $sock.recv(1);
say $beef;
say $beef.bytes;
# get two bytes now
my $babe = $sock.recv(2);
say $babe.bytes;
say $beef.chars;
# get second character
my $babe = $sock.recv(1);
say $babe.chars;
# join it together
$babe ~= $sock.recv(1);
say $babe;
say $babe.bytes;
$sock.close();
}
}
Expand Down
7 changes: 3 additions & 4 deletions S32-io/IO-Socket-INET.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 17;
plan 16;

# L<S32::IO/IO::Socket::INET>

Expand Down Expand Up @@ -90,10 +90,9 @@ if $*OS eq any <linux darwin solaris MSWin32> { # please add more valid OS names
is $expected[$i++], 'abcdefghijklmnopqrstuvwxyz', 'remaining 26 were buffered';
# Multibyte characters
is $expected[$i++], chr(0xbeef), "received {chr 0xbeef}";
is $expected[$i++], 3, '... which is 3 bytes';
is $expected[$i++], 2, 'received 2 bytes of a 3 byte unicode character';
is $expected[$i++], 1, '... which is 1 character';
is $expected[$i++], 1, 'received another character';
is $expected[$i++], chr(0xbabe), "combined the bytes form {chr 0xbabe}";
is $expected[$i++], 3, '... which is 3 bytes';

# test 5 tests get()
if $is-win {
Expand Down

0 comments on commit 89d4c66

Please sign in to comment.