diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-27 10:41:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-27 10:41:43 +0000 |
commit | 7ea65f9be26d17d4bcb50b85301bf5bf379e72ef (patch) | |
tree | e876e5d395d16f4922ce6a8297ab0f422e4d0917 /test/ruby/test_iterator.rb | |
parent | d0fa578cdcb041ec3e42d8bcba0bfcf9984def6d (diff) |
compile.c: try to convert in massign `for`
* compile.c (compile_for_masgn): try to convert to an Array if an
element of massign `for` is not an Array.
[ruby-core:84931] [Bug #14374]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_iterator.rb')
-rw-r--r-- | test/ruby/test_iterator.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb index 9bfa947607..ebfb60354a 100644 --- a/test/ruby/test_iterator.rb +++ b/test/ruby/test_iterator.rb @@ -107,6 +107,16 @@ class TestIterator < Test::Unit::TestCase assert_equal([1, 2, 3, 4, 5, 6, 7], x) end + def test_array_for_masgn + a = [Struct.new(:to_ary).new([1,2])] + x = [] + a.each {|i,j|x << [i,j]} + assert_equal([[1,2]], x) + x = [] + for i,j in a; x << [i,j]; end + assert_equal([[1,2]], x) + end + def test_append_method_to_built_in_class x = [[1,2],[3,4],[5,6]] assert_equal(x.iter_test1{|e|e}, x.iter_test2{|e|e}) |