Permalink
Browse files

Create NoMethodError instance using `mrb_obj_new()`.

  • Loading branch information...
matz committed Mar 2, 2017
1 parent 9b176a1 commit fdd92750fe7e65150b067bc5179e813e7b5e2312
Showing with 5 additions and 20 deletions.
  1. +5 −2 src/error.c
  2. +0 −18 test/t/nomethoderror.rb
View
@@ -519,12 +519,15 @@ MRB_API mrb_noreturn void
mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_value args, char const* fmt, ...)
{
mrb_value exc;
mrb_value argv[3];
va_list ap;
va_start(ap, fmt);
exc = mrb_funcall(mrb, mrb_obj_value(E_NOMETHOD_ERROR), "new", 3,
mrb_vformat(mrb, fmt, ap), mrb_symbol_value(id), args);
argv[0] = mrb_vformat(mrb, fmt, ap);
argv[1] = mrb_symbol_value(id);
argv[2] = args;
va_end(ap);
exc = mrb_obj_new(mrb, E_NOMETHOD_ERROR, 3, argv);
mrb_exc_raise(mrb, exc);
}
View
@@ -20,21 +20,3 @@
end
end
end
assert("NoMethodError#new does not return an exception") do
begin
class << NoMethodError
def new(*)
nil
end
end
assert_raise(TypeError) do
Object.q
end
ensure
class << NoMethodError
remove_method :new
end
end
end

0 comments on commit fdd9275

Please sign in to comment.