summaryrefslogtreecommitdiffstats
path: root/test/ruby/test_iterator.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-31 05:54:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-01-31 05:54:42 +0000
commit27fa603e0733ed9e8b59b6eaa7547d1499394a24 (patch)
tree5db26a44cc57bd827e576419dba0dc1d8957c234 /test/ruby/test_iterator.rb
parent83f7cab371a9e8a029369945bfca417ff5b99902 (diff)
downloadruby-27fa603e0733ed9e8b59b6eaa7547d1499394a24.tar.gz
ruby-27fa603e0733ed9e8b59b6eaa7547d1499394a24.tar.xz
ruby-27fa603e0733ed9e8b59b6eaa7547d1499394a24.zip
* test/ruby/test_iterator.rb (TestIterator::test_block_given_within_iterator):
add new test. [ruby-core:10125] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@11605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_iterator.rb')
-rw-r--r--test/ruby/test_iterator.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb
index 0db54302f..cc0fe76d7 100644
--- a/test/ruby/test_iterator.rb
+++ b/test/ruby/test_iterator.rb
@@ -467,4 +467,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