Add `NoMethodError` tests to `mruby-enumerator`
MODIFY
mrbgems/mruby-enumerator/mrblib/enumerator.rb
mrbgems/mruby-enumerator/mrblib/enumerator.rb
@@ -118,14 +118,9 @@ class Enumerator
def initialize(obj=NONE, meth=:each, *args, &block)
if block
obj = Generator.new(&block)
- else
- if obj == NONE
+ elsif obj == NONE
raise ArgumentError, "wrong number of arguments (given 0, expected 1+)"
end
- if @obj && !self.respond_to?(meth)
- raise NoMethodError, "undefined method #{meth}"
- end
- end
@obj = obj
@meth = meth

MODIFY
mrbgems/mruby-enumerator/test/enumerator.rb
mrbgems/mruby-enumerator/test/enumerator.rb
@@ -6,11 +6,11 @@ class << @obj
end
end
-assert 'Enumerator' do
+assert 'Enumerator.class' do
assert_equal Class, Enumerator.class
end
-assert 'Enumerator' do
+assert 'Enumerator.superclass' do
assert_equal Object, Enumerator.superclass
end
@@ -418,7 +418,10 @@ assert 'nested iteration' do
end
assert 'Kernel#to_enum' do
+ e = nil
assert_equal Enumerator, [].to_enum.class
+ assert_nothing_raised { e = [].to_enum(:_not_implemented_) }
+ assert_raise(NoMethodError) { e.first }
end
assert 'modifying existing methods' do

Add `NoMethodError` tests to `mruby-enumerator`