diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-11 08:29:46 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-11 08:29:46 +0000 |
commit | 7590de68e2102d586a1fb4e34642643b3c731269 (patch) | |
tree | c1d6f0123a404cf538bb353e36889d0fd5865aab /test/ruby/test_io_m17n.rb | |
parent | 756cd2852d8faea5139b01bfd5e596d6f9e35b14 (diff) | |
download | ruby-7590de68e2102d586a1fb4e34642643b3c731269.tar.gz |
* test/ruby/envutil.rb (EnvUtil.with_default_external): add for
changing Encoding.default_external without warnings.
* test/ruby/envutil.rb (EnvUtil.with_default_internal): ditto.
* test/ruby/test_io_m17n.rb: use above with_default_external.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_io_m17n.rb')
-rw-r--r-- | test/ruby/test_io_m17n.rb | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 24a7f16947..45ae75c6aa 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -479,14 +479,13 @@ EOT with_tmpdir { src = "\u3042" generate_file('tmp', src) - defext = Encoding.default_external - Encoding.default_external = Encoding::UTF_8 - open("tmp", "rt") {|f| - s = f.getc - assert_equal(true, s.valid_encoding?) - assert_equal("\u3042", s) - } - Encoding.default_external = defext + EnvUtil.with_default_external(Encoding::UTF_8) do + open("tmp", "rt") {|f| + s = f.getc + assert_equal(true, s.valid_encoding?) + assert_equal("\u3042", s) + } + end } end @@ -494,17 +493,16 @@ EOT with_tmpdir { src = "\xE3\x81" generate_file('tmp', src) - defext = Encoding.default_external - Encoding.default_external = Encoding::UTF_8 - open("tmp", "rt") {|f| - s = f.getc - assert_equal(false, s.valid_encoding?) - assert_equal("\xE3".force_encoding("UTF-8"), s) - s = f.getc - assert_equal(false, s.valid_encoding?) - assert_equal("\x81".force_encoding("UTF-8"), s) - } - Encoding.default_external = defext + EnvUtil.with_default_external(Encoding::UTF_8) do + open("tmp", "rt") {|f| + s = f.getc + assert_equal(false, s.valid_encoding?) + assert_equal("\xE3".force_encoding("UTF-8"), s) + s = f.getc + assert_equal(false, s.valid_encoding?) + assert_equal("\x81".force_encoding("UTF-8"), s) + } + end } end @@ -1681,7 +1679,7 @@ EOT u16 = "\x85\x35\0\r\x00\xa2\0\r\0\n\0\n".force_encoding("utf-16be") i = "\e$B\x42\x22\e(B\r\e$B\x21\x71\e(B\r\n\n".force_encoding("iso-2022-jp") n = system_newline - un = n.encode("utf-16be").force_encoding("ascii-8bit") + n.encode("utf-16be").force_encoding("ascii-8bit") assert_write("a\rb\r#{n}c#{n}", "wt", a) assert_write("\xc2\xa2", "wt", e) |