aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-10 12:30:42 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-10 12:30:42 +0000
commitf466e6fe6fd75868e6314bbc759fdf31dc892e6a (patch)
tree8c7942f2353e5166683b66580bc89b135753f143 /test
parent40fd707c175a577ba5744ca3a5eab4bff37d0023 (diff)
downloadruby-f466e6fe6fd75868e6314bbc759fdf31dc892e6a.tar.gz
io.c: encoding of ARGF.inplace_mode
* io.c (argf_next_argv): encode inplace mode suffix to the path encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/objspace/test_objspace.rb2
-rw-r--r--test/ruby/test_argf.rb23
2 files changed, 24 insertions, 1 deletions
diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb
index 9c706f2736..0e1ad327b9 100644
--- a/test/objspace/test_objspace.rb
+++ b/test/objspace/test_objspace.rb
@@ -45,7 +45,7 @@ class TestObjSpace < Test::Unit::TestCase
argf.inplace_mode = nil
size = ObjectSpace.memsize_of(argf)
argf.inplace_mode = "inplace_mode_suffix"
- assert_equal(size + 20, ObjectSpace.memsize_of(argf))
+ assert_equal(size, ObjectSpace.memsize_of(argf))
end
def test_memsize_of_all
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index 26fe16061e..311469aad9 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -344,6 +344,29 @@ class TestArgf < Test::Unit::TestCase
$stdout = stdout
end
+ def test_inplace_suffix_encoding
+ base = "argf-\u{30c6 30b9 30c8}"
+ name = "#{@tmpdir}/#{base}"
+ suffix = "-bak"
+ File.write(name, "foo")
+ stdout = $stdout
+ argf = ARGF.class.new(name)
+ argf.inplace_mode = suffix.encode(Encoding::UTF_16LE)
+ begin
+ argf.each do |s|
+ puts "+"+s
+ end
+ ensure
+ $stdout.close unless $stdout == stdout
+ $stdout = stdout
+ end
+ assert_file.exist?(name)
+ assert_equal("+foo\n", File.read(name))
+ assert_file.not_exist?(name+"-")
+ assert_file.exist?(name+suffix)
+ assert_equal("foo", File.read(name+suffix))
+ end
+
def test_encoding
ruby('-e', "#{<<~"{#"}\n#{<<~'};'}", @t1.path, @t2.path, @t3.path) do |f|
{#