From ff46ec3a43fc9cb2e128348308d2aea429fb2041 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 31 Jan 2007 05:59:23 +0000 Subject: * eval.c (rb_iterate): need to PUSH_ITER in proper order. [ruby-core:10125] * test/ruby/test_iterator.rb (TestIterator::test_block_given_within_iterator): add new test. [ruby-core:10125] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_iterator.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb index 638916309e..2cd48b29a4 100644 --- a/test/ruby/test_iterator.rb +++ b/test/ruby/test_iterator.rb @@ -462,4 +462,16 @@ class TestIterator < Test::Unit::TestCase assert_equal(ok, result) return end + + class IterString < ::String + def ===(other) + super if !block_given? + end + end + + # Check that the block passed to an iterator + # does not get propagated inappropriately + def test_block_given_within_iterator + assert_equal(["b"], ["a", "b", "c"].grep(IterString.new("b")) {|s| s}) + end end -- cgit v1.2.3