Feature #10498 » 0001-vm_eval.c-loop-now-yields-a-incremented-counter.patch
ChangeLog | ||
---|---|---|
Wed Nov 12 05:57:20 2014 Franck Verrot <franck@verrot.fr>
|
||
* vm_eval.c (loop_i): make loop yield a counter to
|
||
keep track of the iteration count.
|
||
Wed Nov 12 00:26:37 2014 Tanaka Akira <akr@fsij.org>
|
||
* test/ruby/test_object.rb: Specify an exception class for rescue clause.
|
test/ruby/test_enumerator.rb | ||
---|---|---|
}
|
||
end
|
||
def test_loop_yield
|
||
max = 0
|
||
loop do |i|
|
||
max = i
|
||
raise StopIteration if i >= 1
|
||
end
|
||
assert_equal 1, max
|
||
end
|
||
def test_nested_iteration
|
||
def (o = Object.new).each
|
||
yield :ok1
|
vm_eval.c | ||
---|---|---|
static VALUE
|
||
loop_i(void)
|
||
{
|
||
for (;;) {
|
||
rb_yield_0(0, 0);
|
||
for (long int i = 0; i <= FIXNUM_MAX; ++i) {
|
||
rb_yield_values(1, INT2FIX(i));
|
||
}
|
||
return Qnil;
|
||
}
|