summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-26 14:58:44 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-08-26 14:58:44 +0000
commit31875e97b4e11493da07f34096bb4b89180a62b5 (patch)
tree8d879c8196c39e60f6132c225d5fe963b64fb158 /test
parent0170c2fc4df2002568c896176b4c7868dee3e6c3 (diff)
* random.c (random_rand): fixed for edge cases of ranges.
[ruby-dev:39166] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24674 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 446211587f..b6563954cf 100644
--- a/test/ruby/test_rand.rb
+++ b/test/ruby/test_rand.rb
@@ -199,6 +199,14 @@ class TestRand < Test::Unit::TestCase
assert_raise(ArgumentError, '[ruby-core:24677]') { r.rand(-1) }
assert_raise(ArgumentError, '[ruby-core:24677]') { r.rand(-1.0) }
assert_raise(ArgumentError, '[ruby-core:24677]') { r.rand(0) }
+ assert_equal(0, r.rand(1), '[ruby-dev:39166]')
+ assert_equal(0, r.rand(0...1), '[ruby-dev:39166]')
+ assert_equal(0, r.rand(0..0), '[ruby-dev:39166]')
+ assert_equal(0.0, r.rand(0.0..0.0), '[ruby-dev:39166]')
+ assert_raise(ArgumentError, '[ruby-dev:39166]') { r.rand(0...0) }
+ assert_raise(ArgumentError, '[ruby-dev:39166]') { r.rand(0..-1) }
+ assert_raise(ArgumentError, '[ruby-dev:39166]') { r.rand(0.0...0.0) }
+ assert_raise(ArgumentError, '[ruby-dev:39166]') { r.rand(0.0...-0.1) }
end
def test_random_seed