From 2db2fb9f6c742d5bd0019ccd11c7a375e1b12c0b Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Thu, 26 Nov 2020 04:25:42 +0900 Subject: per-ractor Random::DEFAULT Random generators are not Ractor-safe, so we need to prepare per-ractor default random genearators. This patch set `Random::DEFAULT = Randm` (not a Random instance, but the Random class) and singleton methods like `Random.rand()` use a per-ractor random generator. [Feature #17322] --- spec/ruby/core/random/default_spec.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/ruby/core/random/default_spec.rb b/spec/ruby/core/random/default_spec.rb index 1755154294..0333abed6b 100644 --- a/spec/ruby/core/random/default_spec.rb +++ b/spec/ruby/core/random/default_spec.rb @@ -1,8 +1,21 @@ require_relative '../../spec_helper' describe "Random::DEFAULT" do - it "returns a Random instance" do - Random::DEFAULT.should be_an_instance_of(Random) + + it "returns a random number generator" do + Random::DEFAULT.should respond_to(:rand) + end + + ruby_version_is ''...'3.0' do + it "returns a Random instance" do + Random::DEFAULT.should be_an_instance_of(Random) + end + end + + ruby_version_is '3.0' do + it "returns a Random instance" do + Random::DEFAULT.should be_an_instance_of(Class) + end end it "changes seed on reboot" do -- cgit v1.2.3