ruby-changes:3068
From: ko1@a...
Date: 24 Dec 2007 08:57:27 +0900
Subject: [ruby-changes:3068] akr - Ruby:r14560 (trunk): add some tests on conversion for pipe.
akr 2007-12-24 08:57:14 +0900 (Mon, 24 Dec 2007) New Revision: 14560 Modified files: trunk/test/ruby/test_io_m17n.rb Log: add some tests on conversion for pipe. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_io_m17n.rb?r1=14560&r2=14559 Index: test/ruby/test_io_m17n.rb =================================================================== --- test/ruby/test_io_m17n.rb (revision 14559) +++ test/ruby/test_io_m17n.rb (revision 14560) @@ -1,5 +1,6 @@ require 'test/unit' require 'tmpdir' +require 'timeout' class TestIO_M17N < Test::Unit::TestCase ENCS = [ @@ -65,6 +66,39 @@ } end + def test_pipe_terminator_conversion + with_pipe("euc-jp:utf-8") {|r, w| + w.write "before \xa2\xa2 after" + rs = "\xA2\xA2".encode("utf-8", "euc-jp") + timeout(1) { + assert_equal("before \xa2\xa2".encode("utf-8", "euc-jp"), + r.gets(rs)) + } + } + end + + def test_pipe_conversion + with_pipe("euc-jp:utf-8") {|r, w| + w.write "\xa1\xa1" + assert_equal("\xa1\xa1".encode("utf-8", "euc-jp"), r.getc) + } + end + + def test_pipe_convert_partial_read + with_pipe("euc-jp:utf-8") {|r, w| + begin + t = Thread.new { + w.write "\xa1" + sleep 0.1 + w.write "\xa1" + } + assert_equal("\xa1\xa1".encode("utf-8", "euc-jp"), r.getc) + ensure + t.join if t + end + } + end + def test_open_ascii with_tmpdir { src = "abc\n" -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml