mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Remove deprecated Random::DEFAULT [Feature #17351]
This commit is contained in:
parent
84891bffe8
commit
fae0b66431
Notes:
git
2022-01-01 18:56:11 +09:00
3 changed files with 15 additions and 16 deletions
3
random.c
3
random.c
|
@ -1816,9 +1816,6 @@ InitVM_Random(void)
|
|||
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);
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
|
|
@ -317,7 +317,7 @@ class TestRand < Test::Unit::TestCase
|
|||
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
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue