summaryrefslogtreecommitdiff
path: root/spec/ruby/library/stringio/shared/write.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/stringio/shared/write.rb')
-rw-r--r--spec/ruby/library/stringio/shared/write.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/ruby/library/stringio/shared/write.rb b/spec/ruby/library/stringio/shared/write.rb
index 0eb71466e3..c5a0f8f513 100644
--- a/spec/ruby/library/stringio/shared/write.rb
+++ b/spec/ruby/library/stringio/shared/write.rb
@@ -45,6 +45,21 @@ describe :stringio_write_string, shared: true do
@io.pos.should eql(4)
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.write i.to_s
+ }
+ }
+ go = true
+ threads.each(&:join)
+ @io.string.size.should == n.times.map(&:to_s).join.size
+ end
+
ruby_version_is ""..."3.0" do
it "does not taint self when the passed argument is tainted" do
@io.send(@method, "test".taint)