diff options
Diffstat (limited to 'spec/ruby/library/stringio/puts_spec.rb')
-rw-r--r-- | spec/ruby/library/stringio/puts_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/ruby/library/stringio/puts_spec.rb b/spec/ruby/library/stringio/puts_spec.rb index a9f289a5a5..9c890262dd 100644 --- a/spec/ruby/library/stringio/puts_spec.rb +++ b/spec/ruby/library/stringio/puts_spec.rb @@ -101,6 +101,20 @@ describe "StringIO#puts when passed 1 or more objects" do @io.puts '' @io.string.should == "\n" end + + it "handles concurrent writes correctly" do + n = 8 + go = false + threads = n.times.map { |i| + Thread.new { + Thread.pass until go + @io.puts i + } + } + go = true + threads.each(&:join) + @io.string.size.should == n.times.map { |i| "#{i}\n" }.join.size + end end describe "StringIO#puts when passed no arguments" do |