Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update Socket tests to assume character semantics in .recv

  • Loading branch information...
commit 333ca4c63ad7acf2b63f492b13b1dc4b57338dcf 1 parent 24cc87a
@moritz moritz authored
Showing with 10 additions and 13 deletions.
  1. +7 −9 S32-io/IO-Socket-INET.pl
  2. +3 −4 S32-io/IO-Socket-INET.t
View
16 S32-io/IO-Socket-INET.pl
@@ -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();
}
}
@@ -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();
}
}
View
7 S32-io/IO-Socket-INET.t
@@ -1,7 +1,7 @@
use v6;
use Test;
-plan 17;
+plan 16;
# L<S32::IO/IO::Socket::INET>
@@ -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 {
Please sign in to comment.
Something went wrong with that request. Please try again.