diff options
| author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-24 10:40:37 +0000 |
|---|---|---|
| committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-24 10:40:37 +0000 |
| commit | 30960b50811fac7579de17cfea453bdf0da8780c (patch) | |
| tree | 1609ae37b1445c8300d5e628672c0f2f309e735f /test/ruby | |
| parent | 2995440dcba2257ae39511ca6ba05217e62f5b3a (diff) | |
| download | ruby-30960b50811fac7579de17cfea453bdf0da8780c.tar.gz ruby-30960b50811fac7579de17cfea453bdf0da8780c.tar.xz ruby-30960b50811fac7579de17cfea453bdf0da8780c.zip | |
* io.c (rb_io_init_copy): copy encs.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_io_m17n.rb | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index c2254545f..47d04a18d 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -19,8 +19,8 @@ class TestIO_M17N < Test::Unit::TestCase } end - def with_pipe(enc=nil) - r, w = IO.pipe(enc) + def with_pipe(*args) + r, w = IO.pipe(*args) begin yield r, w ensure @@ -239,6 +239,33 @@ EOT w.close if w && !w.closed? end + def test_dup + with_pipe("utf-8:euc-jp") {|r, w| + w << "\u3042" + w.close + r2 = r.dup + begin + assert_equal("\xA4\xA2".force_encoding("euc-jp"), r2.read) + ensure + r2.close + end + + } + end + + def test_dup_undef + with_pipe("utf-8:euc-jp", :undef=>:replace) {|r, w| + w << "\uFFFD" + w.close + r2 = r.dup + begin + assert_equal("?", r2.read) + ensure + r2.close + end + } + end + def test_stdin assert_equal(Encoding.default_external, STDIN.external_encoding) assert_equal(nil, STDIN.internal_encoding) |
