diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-10 05:57:11 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-05-10 05:57:11 +0000 |
commit | b402cc71616169bab03fb856e73a7d6519330ca3 (patch) | |
tree | dadead0ea1a5a4b8e5febef318f9b1b3e60f77c8 /test/ruby/test_rand.rb | |
parent | 518713fd651c8d53a6493a354eadb41361c18029 (diff) |
random.c: use bytes
* random.c (obj_random_bytes): base on bytes method instead of
rand method, not to call toplevel rand method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_rand.rb')
-rw-r--r-- | test/ruby/test_rand.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_rand.rb b/test/ruby/test_rand.rb index d4258a7f1c..c24d6cd1ff 100644 --- a/test/ruby/test_rand.rb +++ b/test/ruby/test_rand.rb @@ -526,6 +526,17 @@ END assert_equal(2, gen.limit, bug7935) end + def test_random_ulong_limited_no_rand + c = Class.new do + undef rand + def bytes(n) + "\0"*n + end + end + gen = c.new.extend(Random::Formatter) + assert_equal(1, [1, 2].sample(random: gen)) + end + def test_default_seed assert_separately([], <<-End) seed = Random::DEFAULT::seed |