Skip to content

Commit 8b677ad

Browse files
committed
Spec that IO#write does not modify its argument
1 parent b826066 commit 8b677ad

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spec/ruby/core/io/shared/write.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@
6969
lambda { IOSpecs.closed_io.send(@method, "hello") }.should raise_error(IOError)
7070
end
7171

72+
it "does not modify the passed argument" do
73+
File.open(@filename, "w") do |f|
74+
f.set_encoding(Encoding::IBM437)
75+
# A character whose codepoint differs between UTF-8 and IBM437
76+
f.write \n".freeze
77+
end
78+
79+
File.binread(@filename).bytes.should == [159, 10]
80+
end
81+
7282
describe "on a pipe" do
7383
before :each do
7484
@r, @w = IO.pipe

0 commit comments

Comments
 (0)