summaryrefslogtreecommitdiff
path: root/spec/ruby
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-11-26 04:25:42 +0900
committerKoichi Sasada <ko1@atdot.net>2020-11-27 17:03:30 +0900
commit2db2fb9f6c742d5bd0019ccd11c7a375e1b12c0b (patch)
treee5f464004a386e2838a700ad5cced540e8f9953c /spec/ruby
parent8ce1711c255679d38b6a2405ff694eb5b5b2eae5 (diff)
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]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3813
Diffstat (limited to 'spec/ruby')
-rw-r--r--spec/ruby/core/random/default_spec.rb17
1 files changed, 15 insertions, 2 deletions
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