summaryrefslogtreecommitdiff
path: root/test/ruby/test_io_m17n.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-24 09:40:31 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-24 09:40:31 +0000
commit071319fde18d319cf5c66702aeaf66ca1a880a2f (patch)
tree765e064f24cabc75e34e456e8d4f443fd1dff9b1 /test/ruby/test_io_m17n.rb
parent571b114708061819db35ad7c0349502196aa92be (diff)
* io.c (rb_io_s_pipe): accept optional hash.
(rb_io_set_encoding): ditto. (rb_io_extract_modeenc): use rb_econv_opts to initialize ecopts. (rb_file_open_generic): ditto. (rb_file_open_internal): ditto. (io_encoding_set): new argument: opt. (argf_set_encoding): copy fptr->encs.opts to argf_ecopts. * transcode.c (rb_econv_opts): accept Qnil for initialization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io_m17n.rb')
-rw-r--r--test/ruby/test_io_m17n.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb
index 93b6de0341..c2254545f3 100644
--- a/test/ruby/test_io_m17n.rb
+++ b/test/ruby/test_io_m17n.rb
@@ -219,6 +219,26 @@ EOT
}
end
+ def test_s_pipe_invalid
+ r, w = IO.pipe("utf-8", "euc-jp", :invalid=>:replace)
+ w << "\x80"
+ w.close
+ assert_equal("?", r.read)
+ ensure
+ r.close if r && !r.closed?
+ w.close if w && !w.closed?
+ end
+
+ def test_s_pipe_undef
+ r, w = IO.pipe("utf-8:euc-jp", :undef=>:replace)
+ w << "\ufffd"
+ w.close
+ assert_equal("?", r.read)
+ ensure
+ r.close if r && !r.closed?
+ w.close if w && !w.closed?
+ end
+
def test_stdin
assert_equal(Encoding.default_external, STDIN.external_encoding)
assert_equal(nil, STDIN.internal_encoding)
@@ -716,6 +736,24 @@ EOT
}
end
+ def test_set_encoding_invalid
+ with_pipe {|r, w|
+ w << "\x80"
+ w.close
+ r.set_encoding("utf-8:euc-jp", :invalid=>:replace)
+ assert_equal("?", r.read)
+ }
+ end
+
+ def test_set_encoding_undef
+ with_pipe {|r, w|
+ w << "\ufffd"
+ w.close
+ r.set_encoding("utf-8", "euc-jp", :undef=>:replace)
+ assert_equal("?", r.read)
+ }
+ end
+
def test_write_conversion_fixenc
with_pipe {|r, w|
w.set_encoding("iso-2022-jp:utf-8")