[MacRuby] #1247: Enumerator#each_with_index does not raise an ArgumentError when was passed argument.
MacRuby
ruby-noreply at macosforge.org
Fri Apr 29 07:52:00 PDT 2011
#1247: Enumerator#each_with_index does not raise an ArgumentError when was passed
argument.
----------------------------------+-----------------------------------------
Reporter: watson1978@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: minor | Milestone:
Component: MacRuby | Keywords:
----------------------------------+-----------------------------------------
Test Script:
{{{
#!ruby
def test(&block)
begin
block.call
rescue ArgumentError
puts " - OK"
else
puts " - NG"
end
end
str = "xyz"
enum = str.enum_for(:each_byte)
puts :each
test{ enum.each(123) }
puts :each_with_index
test{ enum.each_with_index(123) }
}}}
Result:
{{{
$ macruby t.rb
each
- OK
each_with_index
- NG
}}}
Enumerator#each and #each_with_index are written to reject an argument.
{{{
rb_objc_define_method(rb_cEnumerator, "each", enumerator_each, 0);
rb_objc_define_method(rb_cEnumerator, "each_with_index",
enumerator_each_with_index, 0);
}}}
--
Ticket URL: <http://www.macruby.org/trac/ticket/1247>
MacRuby <http://macruby.org/>
More information about the macruby-tickets
mailing list