ruby-changes:70686
From: Nobuyoshi <ko1@a...>
Date: Sat, 1 Jan 2022 18:56:02 +0900 (JST)
Subject: [ruby-changes:70686] fae0b66431 (master): Remove deprecated Random::DEFAULT [Feature #17351]
https://git.ruby-lang.org/ruby.git/commit/?id=fae0b66431 From fae0b664315c23ef7db451f6241d256c12217051 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 1 Jan 2022 11:36:54 +0900 Subject: Remove deprecated Random::DEFAULT [Feature #17351] --- random.c | 3 --- spec/ruby/core/random/default_spec.rb | 20 +++++++++++--------- test/ruby/test_rand.rb | 6 +++--- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/random.c b/random.c index f3dec5cca20..dc7e4771cdc 100644 --- a/random.c +++ b/random.c @@ -1816,9 +1816,6 @@ InitVM_Random(void) https://github.com/ruby/ruby/blob/trunk/random.c#L1816 rb_define_method(rb_cRandom, "seed", random_get_seed, 0); #endif - rb_define_const(rb_cRandom, "DEFAULT", rb_cRandom); - rb_deprecate_constant(rb_cRandom, "DEFAULT"); - rb_define_singleton_method(rb_cRandom, "srand", rb_f_srand, -1); rb_define_singleton_method(rb_cRandom, "rand", random_s_rand, -1); rb_define_singleton_method(rb_cRandom, "bytes", random_s_bytes, 1); diff --git a/spec/ruby/core/random/default_spec.rb b/spec/ruby/core/random/default_spec.rb index 90d3b1720dc..f9270ac7bb3 100644 --- a/spec/ruby/core/random/default_spec.rb +++ b/spec/ruby/core/random/default_spec.rb @@ -1,15 +1,17 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/core/random/default_spec.rb#L1 require_relative '../../spec_helper' -describe "Random::DEFAULT" do - it "returns a random number generator" do - suppress_warning do - Random::DEFAULT.should respond_to(:rand) +ruby_version_is ''...'3.2' do + describe "Random::DEFAULT" do + it "returns a random number generator" do + suppress_warning do + Random::DEFAULT.should respond_to(:rand) + end end - end - it "changes seed on reboot" do - seed1 = ruby_exe('p Random::DEFAULT.seed', options: '--disable-gems') - seed2 = ruby_exe('p Random::DEFAULT.seed', options: '--disable-gems') - seed1.should != seed2 + it "changes seed on reboot" do + seed1 = ruby_exe('p Random::DEFAULT.seed', options: '--disable-gems') + seed2 = ruby_exe('p Random::DEFAULT.seed', options: '--disable-gems') + seed1.should != seed2 + end end end diff --git a/test/ruby/test_rand.rb b/test/ruby/test_rand.rb index 13b7329269f..f066433f6a1 100644 --- a/test/ruby/test_rand.rb +++ b/test/ruby/test_rand.rb @@ -317,7 +317,7 @@ class TestRand < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rand.rb#L317 assert_equal(r1, r2, bug5661) assert_fork_status(1, '[ruby-core:82100] [Bug #13753]') do - Random::DEFAULT.rand(4) + Random.rand(4) end rescue NotImplementedError end @@ -395,8 +395,8 @@ class TestRand < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rand.rb#L395 assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") begin; verbose, $VERBOSE = $VERBOSE, nil - seed = Random::DEFAULT::seed - rand1 = Random::DEFAULT::rand + seed = Random.seed + rand1 = Random.rand $VERBOSE = verbose rand2 = Random.new(seed).rand assert_equal(rand1, rand2) -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/