diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | numeric.c | 2 | ||||
-rw-r--r-- | test/ruby/test_range.rb | 9 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 21 insertions, 2 deletions
@@ -1,3 +1,13 @@ +Sat May 21 01:32:08 2011 NAKAMURA Usaku <usa@ruby-lang.org> + + backported r31286 from trunk + + * numeric.c (ruby_float_step): wrong loop condition. + fixes [ruby-core:35753], reported by Joey Zhou. + + * test/ruby/test_range.rb (TestRange#test_step_ruby_core_35753): + test above change. + Sat May 21 00:55:21 2011 NARUSE, Yui <naruse@ruby-lang.org> * ext/zlib/zlib.c (gzfile_check_footer): ISIZE (Input SIZE) in gzip's @@ -1447,7 +1447,7 @@ ruby_float_step(from, to, step, excl) if (err>0.5) err=0.5; n = floor(n + err); - if (!excl) n++; + if (!excl || ((long)n)*unit+beg < end) n++; for (i=0; i<n; i++) { rb_yield(rb_float_new(i*unit+beg)); } diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 455175087d..14f59e2ff5 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -14,4 +14,13 @@ class TestRange < Test::Unit::TestCase r = (arr.shift)..(arr.shift) assert_equal(1..2, r, "[ruby-dev:26383]") end + + def test_step_ruby_core_35753 + assert_equal(6, (1...6.3).step.to_a.size) + assert_equal(5, (1.1...6).step.to_a.size) + assert_equal(5, (1...6).step(1.1).to_a.size) + assert_equal(3, (1.0...6.3).step(1.8).to_a.size) + assert_equal(3, (1.0...6.4).step(1.8).to_a.size) + assert_equal(4, (1.0...6.5).step(1.8).to_a.size) + end end @@ -2,7 +2,7 @@ #define RUBY_RELEASE_DATE "2011-05-21" #define RUBY_VERSION_CODE 187 #define RUBY_RELEASE_CODE 20110521 -#define RUBY_PATCHLEVEL 339 +#define RUBY_PATCHLEVEL 341 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 |