Commit 208bafba authored by take_cheeze's avatar take_cheeze

Move Kernel#fail definition to mruby-kernel-ext mrbgem.

parent 98a61083
......@@ -21,6 +21,9 @@ void mrb_print_backtrace(mrb_state *mrb);
mrb_value mrb_exc_backtrace(mrb_state *mrb, mrb_value exc);
mrb_value mrb_get_backtrace(mrb_state *mrb);
/* declaration for fail method */
mrb_value mrb_f_raise(mrb_state*, mrb_value);
#if defined(__cplusplus)
} /* extern "C" { */
#endif
......
MRuby::Gem::Specification.new('mruby-kernel-ext') do |spec|
spec.license = 'MIT'
spec.author = 'mruby developers'
spec.summary = 'extensional Kernel module'
end
#include <mruby.h>
#include <mruby/error.h>
void
mrb_mruby_kernel_ext_gem_init(mrb_state *mrb)
{
struct RClass *krn = mrb->kernel_module;
mrb_define_module_function(mrb, krn, "fail", mrb_f_raise, MRB_ARGS_NONE());
}
void
mrb_mruby_kernel_ext_gem_final(mrb_state *mrb)
{
}
assert('Kernel.fail, Kernel#fail') do
assert_raise(RuntimeError) { fail }
assert_raise(RuntimeError) { Kernel.fail }
end
......@@ -924,7 +924,7 @@ mrb_obj_public_methods(mrb_state *mrb, mrb_value self)
* raise "Failed to create socket"
* raise ArgumentError, "No parameters", caller
*/
static mrb_value
mrb_value
mrb_f_raise(mrb_state *mrb, mrb_value self)
{
mrb_value a[2], exc;
......@@ -1189,8 +1189,6 @@ mrb_init_kernel(mrb_state *mrb)
mrb_define_method(mrb, krn, "to_s", mrb_any_to_s, MRB_ARGS_NONE()); /* 15.3.1.3.46 */
mrb_define_method(mrb, krn, "__case_eqq", mrb_obj_ceqq, MRB_ARGS_REQ(1)); /* internal */
mrb_define_module_function(mrb, krn, "fail", mrb_f_raise, MRB_ARGS_NONE());
mrb_include_module(mrb, mrb->object_class, mrb->kernel_module);
mrb_alias_method(mrb, mrb->module_class, mrb_intern_lit(mrb, "dup"), mrb_intern_lit(mrb, "clone"));
}
......@@ -563,7 +563,3 @@ assert('stack extend') do
end
end
assert('Kernel.fail, Kernel#fail') do
assert_raise(RuntimeError) { fail }
assert_raise(RuntimeError) { Kernel.fail }
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment