mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add test for ractor race condition on ivar sets
This commit is contained in:
parent
fb99227ca1
commit
9a5684bf7f
Notes:
git
2022-10-15 04:00:04 +09:00
1 changed files with 39 additions and 0 deletions
|
@ -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']
|
||||
|
|
Loading…
Reference in a new issue