subtest "echo utf8" => sub { foreach my $msg ("simple", "", ("a" x 32768), "unicode \u2603 snowman", "hiragana \u3072\u3089\u304c\u306a null \x00 ctrls \cA \cF \n \e del \x7f end") { print $sock Protocol::WebSocket::Frame->new(type=>'text', buffer=>$msg)->to_bytes; my $bytes = _recv($sock => $parser); ok($parser->is_text, "expected text message"); is($bytes, "utf8(" . length($msg) . ") = $msg"); } }; subtest "echo binary" => sub { foreach my $msg ("simple", "", ("a" x 32768), "unicode \u2603 snowman", "hiragana \u3072\u3089\u304c\u306a null \x00 ctrls \cA \cF \n \e del \x7f end", join("", map{chr($_)} 0..255)) { print $sock Protocol::WebSocket::Frame->new(type=>'binary', buffer=>$msg)->to_bytes; my $bytes = _recv($sock => $parser); ok($parser->is_binary, "expected binary message"); is($bytes, "binary(" . length($msg) . ") = $msg"); } };