diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-29 22:50:11 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-05-29 22:50:11 +0000 |
commit | f0de89f81ae37ed8b12427c375bc5ad06bcfba0e (patch) | |
tree | 86bb303355c3078ca116debb66e88d411625af28 | |
parent | f13e0ec80e9c98e42db2e0d48978c60c64c7cf6d (diff) |
merges r31286 from trunk into ruby_1_9_2.
--
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@31803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | numeric.c | 2 | ||||
-rw-r--r-- | test/ruby/test_range.rb | 9 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 19 insertions, 2 deletions
@@ -1,3 +1,11 @@ +Thu Apr 14 23:43:43 2011 NAKAMURA Usaku <usa@ruby-lang.org> + + * 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. + Thu Apr 14 21:21:06 2011 Nobuyoshi Nakada <nobu@ruby-lang.org> * include/ruby/win32.h (frexp, modf): wrongly declared as pure in @@ -1592,7 +1592,7 @@ ruby_float_step(VALUE from, VALUE to, VALUE step, int excl) else { 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(DBL2NUM(i*unit+beg)); } diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index a2935955de..12ba47c219 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -182,6 +182,15 @@ class TestRange < Test::Unit::TestCase assert_nothing_raised("[ruby-dev:34558]") { (0..2).step(o) {|x| } } 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 + def test_each a = [] (0..10).each {|x| a << x } @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 230 +#define RUBY_PATCHLEVEL 231 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 |