From cfa7550b6680fac48fcdc9d5c80dadeb71186dae Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 15 Aug 2015 01:15:22 +0000 Subject: io.c: read more data * io.c (rb_io_each_codepoint): read more data when read partially. [ruby-core:70379] [Bug #11444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io_m17n.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 4382824844..55e23a2768 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -2562,4 +2562,24 @@ EOT a.close rescue nil b.close rescue nil end + + def test_each_codepoint_need_more + code = <<-'end;' + c = nil + begin + STDIN.set_encoding(Encoding::UTF_8).each_codepoint{|i| c = i} + rescue ArgumentError => e + STDERR.puts e.message + else + printf "%x", c + end + end; + args = ['-e', code] + bug11444 = '[ruby-core:70379] [Bug #11444]' + assert_in_out_err(args, "\u{1f376}".b[0,3], [], + ["invalid byte sequence in UTF-8"], + bug11444, timeout: 1) + assert_in_out_err(args, "x"*8190+"\u{1f376}", ["1f376"], [], + bug11444, timeout: 1) + end end -- cgit v1.2.3