diff options
Diffstat (limited to 'spec/ruby/library/stringio/putc_spec.rb')
-rw-r--r-- | spec/ruby/library/stringio/putc_spec.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/library/stringio/putc_spec.rb b/spec/ruby/library/stringio/putc_spec.rb index 223b3523e5..1ce53b7ef2 100644 --- a/spec/ruby/library/stringio/putc_spec.rb +++ b/spec/ruby/library/stringio/putc_spec.rb @@ -35,6 +35,21 @@ describe "StringIO#putc when passed [String]" do @io.putc("t") @io.pos.should == 3 end + + it "handles concurrent writes correctly" do + @io = StringIO.new + n = 8 + go = false + threads = n.times.map { |i| + Thread.new { + Thread.pass until go + @io.putc i.to_s + } + } + go = true + threads.each(&:join) + @io.string.size.should == n + end end describe "StringIO#putc when passed [Object]" do |