diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-11-07 19:33:41 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2024-11-07 19:33:41 +0900 |
| commit | 1701ddea73cf482289361c7559ad42e2694f65f1 (patch) | |
| tree | f7026a2715c3f9a53ca3a238905cdfe10762230d /test/ruby | |
| parent | ffcfaf4ce4eba4975f6ef79bf4b6c898180107f2 (diff) | |
[Bug #20802] Copy encodings at reopen as well
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/12022
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_io.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index a623fd1d15..5d4ede1e4f 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -2655,6 +2655,17 @@ class TestIO < Test::Unit::TestCase } end + def test_reopen_binmode + f1 = File.open(__FILE__) + f2 = File.open(__FILE__) + f1.binmode + f1.reopen(f2) + assert_not_operator(f1, :binmode?) + ensure + f2.close + f1.close + end + def make_tempfile_for_encoding t = make_tempfile open(t.path, "rb+:utf-8") {|f| f.puts "\u7d05\u7389bar\n"} @@ -2685,6 +2696,16 @@ class TestIO < Test::Unit::TestCase } end + def test_reopen_encoding_from_io + f1 = File.open(__FILE__, "rb:UTF-16LE") + f2 = File.open(__FILE__, "r:UTF-8") + f1.reopen(f2) + assert_equal(Encoding::UTF_8, f1.external_encoding) + ensure + f2.close + f1.close + end + def test_reopen_opt_encoding feature7103 = '[ruby-core:47806]' make_tempfile_for_encoding {|t| |
