diff options
-rw-r--r-- | test/ruby/test_enumerator.rb | 4 | ||||
-rw-r--r-- | vm_eval.c | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/test/ruby/test_enumerator.rb b/test/ruby/test_enumerator.rb index 49d7827d35..b2ef8e5c25 100644 --- a/test/ruby/test_enumerator.rb +++ b/test/ruby/test_enumerator.rb @@ -464,5 +464,9 @@ class TestEnumerator < Test::Unit::TestCase assert_equal 0, [].cycle.size assert_equal 0, [].cycle(5).size end + + def test_size_for_loops + assert_equal Float::INFINITY, loop.size + end end @@ -920,6 +920,11 @@ loop_i(void) return Qnil; } +static VALUE +rb_f_loop_size(VALUE self, VALUE args) { + return DBL2NUM(INFINITY); +} + /* * call-seq: * loop { block } @@ -942,7 +947,7 @@ loop_i(void) static VALUE rb_f_loop(VALUE self) { - RETURN_ENUMERATOR(self, 0, 0); + RETURN_SIZED_ENUMERATOR(self, 0, 0, rb_f_loop_size); rb_rescue2(loop_i, (VALUE)0, 0, 0, rb_eStopIteration, (VALUE)0); return Qnil; /* dummy */ } |