diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-10 07:30:47 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-03-10 07:30:47 +0000 |
| commit | 453f94c2b2d209050d2aabd1eabf1093b9293b35 (patch) | |
| tree | 81b2b9c7a8397620ba1c959e12f6778b6d8cb50a /test/ruby/test_iterator.rb | |
| parent | bbbd594c3c6da43c08332c2e63737f8e8fe4846e (diff) | |
* eval.c (rb_f_loop): Return an enumerator if no block is given.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@26864 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_iterator.rb')
| -rw-r--r-- | test/ruby/test_iterator.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb index 2cd48b29a4..60c589efef 100644 --- a/test/ruby/test_iterator.rb +++ b/test/ruby/test_iterator.rb @@ -474,4 +474,25 @@ class TestIterator < Test::Unit::TestCase def test_block_given_within_iterator assert_equal(["b"], ["a", "b", "c"].grep(IterString.new("b")) {|s| s}) end + + def test_loop + i = 0 + loop { + i = 1 + break + } + assert_equal(1, i) + + i = 0 + loop { + i += 1 + break if i > 1 + } + assert_equal(2, i) + + assert_nothing_raised { + x = loop + assert_kind_of(Enumerable, x) + } + end end |
