mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Removed Module.allocate [Bug #17048]
This commit is contained in:
parent
178ee1e801
commit
fd918d1afa
Notes:
git
2021-09-17 19:05:25 +09:00
3 changed files with 2 additions and 26 deletions
2
object.c
2
object.c
|
@ -4612,6 +4612,7 @@ InitVM_Object(void)
|
||||||
rb_define_method(rb_cModule, "attr_accessor", rb_mod_attr_accessor, -1);
|
rb_define_method(rb_cModule, "attr_accessor", rb_mod_attr_accessor, -1);
|
||||||
|
|
||||||
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
|
rb_define_alloc_func(rb_cModule, rb_module_s_alloc);
|
||||||
|
rb_undef_method(rb_singleton_class(rb_cModule), "allocate");
|
||||||
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
|
rb_define_method(rb_cModule, "initialize", rb_mod_initialize, 0);
|
||||||
rb_define_method(rb_cModule, "initialize_clone", rb_mod_initialize_clone, -1);
|
rb_define_method(rb_cModule, "initialize_clone", rb_mod_initialize_clone, -1);
|
||||||
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */
|
rb_define_method(rb_cModule, "instance_methods", rb_class_instance_methods, -1); /* in class.c */
|
||||||
|
@ -4643,6 +4644,7 @@ InitVM_Object(void)
|
||||||
rb_define_method(rb_cModule, "deprecate_constant", rb_mod_deprecate_constant, -1); /* in variable.c */
|
rb_define_method(rb_cModule, "deprecate_constant", rb_mod_deprecate_constant, -1); /* in variable.c */
|
||||||
rb_define_method(rb_cModule, "singleton_class?", rb_mod_singleton_p, 0);
|
rb_define_method(rb_cModule, "singleton_class?", rb_mod_singleton_p, 0);
|
||||||
|
|
||||||
|
rb_define_method(rb_singleton_class(rb_cClass), "allocate", rb_class_alloc_m, 0);
|
||||||
rb_define_method(rb_cClass, "allocate", rb_class_alloc_m, 0);
|
rb_define_method(rb_cClass, "allocate", rb_class_alloc_m, 0);
|
||||||
rb_define_method(rb_cClass, "new", rb_class_new_instance_pass_kw, -1);
|
rb_define_method(rb_cClass, "new", rb_class_new_instance_pass_kw, -1);
|
||||||
rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1);
|
rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1);
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
require_relative '../../spec_helper'
|
|
||||||
|
|
||||||
describe "Module.allocate" do
|
|
||||||
it "returns an instance of Module" do
|
|
||||||
mod = Module.allocate
|
|
||||||
mod.should be_an_instance_of(Module)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "returns a fully-formed instance of Module" do
|
|
||||||
mod = Module.allocate
|
|
||||||
mod.constants.should_not == nil
|
|
||||||
mod.methods.should_not == nil
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -3094,18 +3094,6 @@ class TestModule < Test::Unit::TestCase
|
||||||
assert_match(/::Foo$/, mod.name, '[Bug #14895]')
|
assert_match(/::Foo$/, mod.name, '[Bug #14895]')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_include_allocated
|
|
||||||
assert_raise(ArgumentError) do
|
|
||||||
Module.new {include Module.allocate}
|
|
||||||
end
|
|
||||||
assert_raise(ArgumentError) do
|
|
||||||
Module.new {prepend Module.allocate}
|
|
||||||
end
|
|
||||||
assert_raise(ArgumentError) do
|
|
||||||
Object.new.extend Module.allocate
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def assert_top_method_is_private(method)
|
def assert_top_method_is_private(method)
|
||||||
|
|
Loading…
Reference in a new issue