aboutsummaryrefslogtreecommitdiffstats
path: root/bootstraptest/test_ractor.rb
diff options
context:
space:
mode:
authorJemma Issroff <jemmaissroff@gmail.com>2022-10-04 15:27:13 -0400
committerJohn Hawthorn <john@hawthorn.email>2022-10-14 11:59:36 -0700
commit9a5684bf7f92ae71a55ede82ec18c31c161694ec (patch)
treee2c3221e47d5486ba3c4ec1eb00b6f336d2013d7 /bootstraptest/test_ractor.rb
parentfb99227ca1ee9d8540d251c8b61c3e6433211714 (diff)
downloadruby-9a5684bf7f92ae71a55ede82ec18c31c161694ec.tar.gz
Add test for ractor race condition on ivar sets
Diffstat (limited to 'bootstraptest/test_ractor.rb')
-rw-r--r--bootstraptest/test_ractor.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb
index b29db7ab0e..6373349e42 100644
--- a/bootstraptest/test_ractor.rb
+++ b/bootstraptest/test_ractor.rb
@@ -1579,4 +1579,43 @@ assert_equal "ok", %q{
end
}
+assert_equal "ok", %q{
+ module M
+ def foo
+ @foo
+ end
+ end
+
+ class A
+ include M
+
+ def initialize
+ 100.times { |i| instance_variable_set(:"@var_#{i}", "bad: #{i}") }
+ @foo = 2
+ end
+ end
+
+ class B
+ include M
+
+ def initialize
+ @foo = 1
+ end
+ end
+
+ Ractor.new do
+ b = B.new
+ 100_000.times do
+ raise unless b.foo == 1
+ end
+ end
+
+ a = A.new
+ 100_000.times do
+ raise unless a.foo == 2
+ end
+
+ "ok"
+}
+
end # if !ENV['GITHUB_WORKFLOW']