Commit abe6db94 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

resolve conflict #1552

parents ad4ce2ba 12e00f92
......@@ -1080,15 +1080,18 @@ mrb_obj_new(mrb_state *mrb, struct RClass *c, int argc, mrb_value *argv)
static mrb_value
mrb_class_new_class(mrb_state *mrb, mrb_value cv)
{
mrb_value super;
struct RClass *new_class;
mrb_value super, blk;
mrb_value new_class;
if (mrb_get_args(mrb, "|C", &super) == 0) {
if (mrb_get_args(mrb, "|C&", &super, &blk) == 0) {
super = mrb_obj_value(mrb->object_class);
}
new_class = mrb_class_new(mrb, mrb_class_ptr(super));
mrb_funcall(mrb, super, "inherited", 1, mrb_obj_value(new_class));
return mrb_obj_value(new_class);
new_class = mrb_obj_value(mrb_class_new(mrb, mrb_class_ptr(super)));
if (!mrb_nil_p(blk)) {
mrb_funcall_with_block(mrb, new_class, mrb_intern_cstr(mrb, "class_eval"), 0, NULL, blk);
}
mrb_funcall(mrb, super, "inherited", 1, new_class);
return new_class;
}
mrb_value
......
......@@ -9,7 +9,15 @@ assert('Class superclass', '15.2.3.2') do
assert_equal(Module, Class.superclass)
end
# Class#initialize '15.2.3.3.1' is tested in Class#new
assert('Class#initialize', '15.2.3.3.1') do
c = Class.new do
def test
:test
end
end.new
assert_equal(c.test, :test)
end
assert('Class#initialize_copy', '15.2.3.3.2') do
class TestClass
......
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