diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-15 06:14:16 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-15 06:14:16 +0000 |
| commit | 498d8031e23234a3cf8aebd185128ac7bcc35522 (patch) | |
| tree | 98f424f4c8015a380efb002f2a7ad403f320d366 /test/ruby | |
| parent | e2f40d88894700b532d7c187aef3e2a5e8be1d5a (diff) | |
| download | ruby-498d8031e23234a3cf8aebd185128ac7bcc35522.tar.gz ruby-498d8031e23234a3cf8aebd185128ac7bcc35522.tar.xz ruby-498d8031e23234a3cf8aebd185128ac7bcc35522.zip | |
* io.c (io_encoding_set): get rid of parsing non-ascii string, and
refine messages for invalid name encoding.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_io_m17n.rb | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 6f5e686c4..976aae8c2 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -220,33 +220,27 @@ 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? + with_pipe("utf-8", "euc-jp", :invalid=>:replace) {|r, w| + w << "\x80" + w.close + assert_equal("?", r.read) + } 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? + with_pipe("utf-8:euc-jp", :undef=>:replace) {|r, w| + w << "\ufffd" + w.close + assert_equal("?", r.read) + } end def test_s_pipe_undef_replace_string - r, w = IO.pipe("utf-8:euc-jp", :undef=>:replace, :replace=>"X") - w << "\ufffd" - w.close - assert_equal("X", r.read) - ensure - r.close if r && !r.closed? - w.close if w && !w.closed? + with_pipe("utf-8:euc-jp", :undef=>:replace, :replace=>"X") {|r, w| + w << "\ufffd" + w.close + assert_equal("X", r.read) + } end def test_dup @@ -572,6 +566,11 @@ EOT assert_equal(eucjp, r.read) } + e = assert_raise(ArgumentError) {with_pipe("UTF-8", "UTF-8".encode("UTF-32BE")) {}} + assert_match(/invalid name encoding/, e.message) + e = assert_raise(ArgumentError) {with_pipe("UTF-8".encode("UTF-32BE")) {}} + assert_match(/invalid name encoding/, e.message) + ENCS.each {|enc| with_pipe(enc) {|r, w| w << "\xc2\xa1" |
