From 76c02f05a27a5dfaac3e7b8fe4865212c57cfd13 Mon Sep 17 00:00:00 2001 From: akr Date: Fri, 12 Sep 2008 17:58:58 +0000 Subject: * io.c (validate_enc_binmode): extracted from rb_io_extract_modeenc. (rb_io_extract_modeenc): use validate_enc_binmode. (io_encoding_set): call validate_enc_binmode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_io_m17n.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/ruby/test_io_m17n.rb') diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 85401d6aaf..087f8c4483 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -807,6 +807,24 @@ EOT } end + def test_set_encoding_binmode + assert_raise(ArgumentError) { + open("/dev/null", "rt") {|f| + f.set_encoding("iso-2022-jp") + } + } + assert_raise(ArgumentError) { + open("/dev/null", "r") {|f| + f.set_encoding("iso-2022-jp") + } + } + assert_nothing_raised { + open("/dev/null", "rb") {|f| + f.set_encoding("iso-2022-jp") + } + } + end + def test_write_conversion_fixenc with_pipe {|r, w| w.set_encoding("iso-2022-jp:utf-8") -- cgit v1.2.3