summaryrefslogtreecommitdiff
path: root/test/ruby/test_argf.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/ruby/test_argf.rb')
-rw-r--r--test/ruby/test_argf.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index a112cf3e848..26fe16061ea 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -316,6 +316,34 @@ class TestArgf < Test::Unit::TestCase
}
end
+ def test_inplace_to_path
+ base = "argf-test"
+ name = "#{@tmpdir}/#{base}"
+ File.write(name, "foo")
+ stdout = $stdout
+ argf = ARGF.class.new(Struct.new(:to_path).new(name))
+ begin
+ result = argf.gets
+ ensure
+ $stdout = stdout
+ argf.close
+ end
+ assert_equal("foo", result)
+ end
+
+ def test_inplace_ascii_incompatible_path
+ base = "argf-\u{30c6 30b9 30c8}"
+ name = "#{@tmpdir}/#{base}"
+ File.write(name, "foo")
+ stdout = $stdout
+ argf = ARGF.class.new(name.encode(Encoding::UTF_16LE))
+ assert_raise(Encoding::CompatibilityError) do
+ argf.gets
+ end
+ ensure
+ $stdout = stdout
+ end
+
def test_encoding
ruby('-e', "#{<<~"{#"}\n#{<<~'};'}", @t1.path, @t2.path, @t3.path) do |f|
{#