ruby-changes:32071
From: nagachika <ko1@a...>
Date: Fri, 13 Dec 2013 01:02:14 +0900 (JST)
Subject: [ruby-changes:32071] nagachika:r44150 (ruby_2_0_0): merge revision(s) 39722: [Backport #9178]
nagachika 2013-12-13 01:02:08 +0900 (Fri, 13 Dec 2013) New Revision: 44150 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44150 Log: merge revision(s) 39722: [Backport #9178] * enumerator.c (enumerator_with_index): try to convert given offset to integer. fix bug introduced in r39594. Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/enumerator.c branches/ruby_2_0_0/test/ruby/test_enumerator.rb branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 44149) +++ ruby_2_0_0/ChangeLog (revision 44150) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Fri Dec 13 00:23:01 2013 NARUSE, Yui <naruse@r...> + + * enumerator.c (enumerator_with_index): try to convert given offset to + integer. fix bug introduced in r39594. + Mon Dec 2 23:31:00 2013 Nobuyoshi Nakada <nobu@r...> * enumerator.c (enumerator_with_index): should not store local variable Index: ruby_2_0_0/enumerator.c =================================================================== --- ruby_2_0_0/enumerator.c (revision 44149) +++ ruby_2_0_0/enumerator.c (revision 44150) @@ -493,7 +493,9 @@ enumerator_with_index(int argc, VALUE *a https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/enumerator.c#L493 rb_scan_args(argc, argv, "01", &memo); RETURN_SIZED_ENUMERATOR(obj, argc, argv, enumerator_size); if (NIL_P(memo)) - memo = INT2NUM(0); + memo = INT2FIX(0); + else + memo = rb_to_int(memo); return enumerator_block_call(obj, enumerator_with_index_i, (VALUE)NEW_MEMO(memo, 0, 0)); } Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 44149) +++ ruby_2_0_0/version.h (revision 44150) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" -#define RUBY_RELEASE_DATE "2013-12-02" -#define RUBY_PATCHLEVEL 357 +#define RUBY_RELEASE_DATE "2013-12-13" +#define RUBY_PATCHLEVEL 358 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 12 -#define RUBY_RELEASE_DAY 2 +#define RUBY_RELEASE_DAY 13 #include "ruby/version.h" Index: ruby_2_0_0/test/ruby/test_enumerator.rb =================================================================== --- ruby_2_0_0/test/ruby/test_enumerator.rb (revision 44149) +++ ruby_2_0_0/test/ruby/test_enumerator.rb (revision 44150) @@ -112,6 +112,18 @@ class TestEnumerator < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_enumerator.rb#L112 assert_equal([[1,s],[2,s+1],[3,s+2]], @obj.to_enum(:foo, 1, 2, 3).with_index(s).to_a, bug8010) end + def test_with_index_nonnum_offset + bug8010 = '[ruby-dev:47131] [Bug #8010]' + s = Object.new + def s.to_int; 1 end + assert_equal([[1,1],[2,2],[3,3]], @obj.to_enum(:foo, 1, 2, 3).with_index(s).to_a, bug8010) + end + + def test_with_index_string_offset + bug8010 = '[ruby-dev:47131] [Bug #8010]' + assert_raise(TypeError, bug8010){ @obj.to_enum(:foo, 1, 2, 3).with_index('1').to_a } + end + def test_with_index_dangling_memo bug9178 = '[ruby-core:58692] [Bug #9178]' assert_separately([], <<-"end;") Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r39722 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/