ruby-changes:12645
From: nobu <ko1@a...>
Date: Mon, 3 Aug 2009 00:32:24 +0900 (JST)
Subject: [ruby-changes:12645] Ruby:r24358 (trunk): * random.c (rb_random_int): arguments have to be converted to
nobu 2009-08-03 00:32:04 +0900 (Mon, 03 Aug 2009) New Revision: 24358 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24358 Log: * random.c (rb_random_int): arguments have to be converted to integer. [ruby-core:24679] Modified files: trunk/ChangeLog trunk/random.c trunk/test/ruby/test_rand.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 24357) +++ ChangeLog (revision 24358) @@ -1,3 +1,8 @@ +Mon Aug 3 00:32:00 2009 Nobuyoshi Nakada <nobu@r...> + + * random.c (rb_random_int): arguments have to be converted to + integer. [ruby-core:24679] + Sun Aug 2 21:04:37 2009 Nobuyoshi Nakada <nobu@r...> * parse.y (literal_concat0): tail can be nil. [ruby-dev:38980] Index: test/ruby/test_rand.rb =================================================================== --- test/ruby/test_rand.rb (revision 24357) +++ test/ruby/test_rand.rb (revision 24358) @@ -344,6 +344,7 @@ 1267650600228229401496703205383).each do |w| assert_equal(w.to_i, r.int(2**100+5..2**100+9)) end + assert_equal(3, r.int(3.1..4), '[ruby-core:24679]') end def test_random_float Index: random.c =================================================================== --- random.c (revision 24357) +++ random.c (revision 24358) @@ -911,9 +911,10 @@ if (NIL_P(v)) { /* range like object support */ if (!(v = range_values(vmax, &beg))) { - beg = Qundef; - NUM2LONG(vmax); + v = vmax; } + v = rb_to_int(v); + beg = rb_to_int(beg); } v = rand_int(&rnd->mt, v); if (NIL_P(v)) v = INT2FIX(0); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/