aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_rand.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-24 06:33:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-24 06:33:49 +0000
commitd64c926eba3a317f4756e048d2ef7522c463636d (patch)
treeeb1a3f91baa522fb5401b0f1a8c121d6a45e279f /test/ruby/test_rand.rb
parent023561f704f51804d0803ff2c1839901d609a83d (diff)
downloadruby-d64c926eba3a317f4756e048d2ef7522c463636d.tar.gz
random.c: increase limit for generic rand
* random.c (rb_random_ulong_limited): limit is inclusive, but generic rand method should return a number less than it, so increase for the difference. [ruby-core:52779] [Bug #7935] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_rand.rb')
-rw-r--r--test/ruby/test_rand.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_rand.rb b/test/ruby/test_rand.rb
index 9fabfc607f..611e9f57a0 100644
--- a/test/ruby/test_rand.rb
+++ b/test/ruby/test_rand.rb
@@ -528,5 +528,13 @@ END
def (gen = Object.new).rand(*) -1 end
e = assert_raise(RangeError) {[1,2,3].sample(random: gen)}
assert_match(/small -1\z/, e.message, bug7903)
+
+ bug7935 = '[ruby-core:52779] [Bug #7935]'
+ class << (gen = Object.new)
+ def rand(limit) @limit = limit; 0 end
+ attr_reader :limit
+ end
+ [1, 2].sample(1, random: gen)
+ assert_equal(2, gen.limit, bug7935)
end
end