summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-02 14:48:50 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-02 14:48:50 +0000
commitc27bd84806454f4627d8957a87b6186da1aab089 (patch)
treead209293976fac561c18e38dfc2a0a90e68465a5 /test
parentb851418bb7bfa498566c548bd5ea535cc13aa2eb (diff)
merge revision(s) 43929: [Backport #9178]
* enumerator.c (enumerator_with_index): should not store local variable address to memoise the arguments. it is invalidated after the return. [ruby-core:58692] [Bug #9178] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_enumerator.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb
index 8843d8d732..9e2502a965 100644
--- a/test/ruby/test_enumerator.rb
+++ b/test/ruby/test_enumerator.rb
@@ -112,6 +112,16 @@ class TestEnumerator < Test::Unit::TestCase
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_dangling_memo
+ bug9178 = '[ruby-core:58692] [Bug #9178]'
+ assert_separately([], <<-"end;")
+ bug = "#{bug9178}"
+ e = [1].to_enum(:chunk).with_index {|c,i| i == 5}
+ assert_kind_of(Enumerator, e)
+ assert_equal([false, [1]], e.to_a[0], bug)
+ end;
+ end
+
def test_with_object
obj = [0, 1]
ret = (1..10).each.with_object(obj) {|i, memo|