Project

General

Profile

Bug #8767 » 0001-io.c-IO.copy_stream-should-write-in-binary-mode.patch

added a test case - godfat (Lin Jen-Shin), 08/12/2013 03:07 AM

View differences:

io.c
args[1] = INT2NUM(oflags);
args[2] = INT2FIX(0666);
dst_io = rb_class_new_instance(3, args, rb_cFile);
rb_io_binmode_m(dst_io);
stp->dst = dst_io;
stp->close_dst = 1;
}
test/ruby/test_io.rb
}
end
def test_copy_stream_to_obj_with_to_path_in_binmode
mkcdtmpdir {
EnvUtil.with_default_internal(Encoding::UTF_8) do
# StringIO to object with to_path
bytes = "\xDE\xAD\xBE\xEF".force_encoding(Encoding::ASCII_8BIT)
src = StringIO.new(bytes)
dst = Object.new
def dst.to_path
"qux"
end
IO.copy_stream(src, dst)
assert_equal(bytes, File.binread("qux"))
assert_equal(4, src.pos)
end
}
end
class Rot13IO
def initialize(io)
@io = io
(2-2/2)