* eval.c: remove Module#refinements.

* test/ruby/test_refinement.rb: remove tests for Module#refinements.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shugo 2012-12-08 13:35:15 +00:00
Родитель bdb8607cb7
Коммит 4363d0765b
3 изменённых файлов: 8 добавлений и 93 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Sat Dec 8 22:33:26 2012 Shugo Maeda <shugo@ruby-lang.org>
* eval.c: remove Module#refinements.
* test/ruby/test_refinement.rb: remove tests for Module#refinements.
Sat Dec 8 13:17:55 2012 Shugo Maeda <shugo@ruby-lang.org>
* eval.c (top_using): raise a RuntimeError if using is called in a

32
eval.c
Просмотреть файл

@ -1237,37 +1237,6 @@ rb_mod_refine(VALUE module, VALUE klass)
return refinement;
}
static int
refinements_i(VALUE key, VALUE value, VALUE arg)
{
rb_hash_aset(arg, key, value);
return ST_CONTINUE;
}
/*
* call-seq:
* refinements -> hash
*
* Returns refinements in the receiver as a hash table, whose key is a
* refined class and whose value is a refinement module.
*/
static VALUE
rb_mod_refinements(VALUE module)
{
ID id_refinements;
VALUE refinements, result;
CONST_ID(id_refinements, "__refinements__");
refinements = rb_attr_get(module, id_refinements);
if (NIL_P(refinements)) {
return rb_hash_new();
}
result = rb_hash_new();
rb_hash_foreach(refinements, refinements_i, result);
return result;
}
void
rb_obj_call_init(VALUE obj, int argc, VALUE *argv)
{
@ -1619,7 +1588,6 @@ ruby_Init_refinement(void)
{
rb_define_private_method(rb_cModule, "refine", rb_mod_refine, 1);
rb_undef_method(rb_cClass, "refine");
rb_define_method(rb_cModule, "refinements", rb_mod_refinements, 0);
rb_define_private_method(rb_singleton_class(rb_vm_top_self()),
"using", top_using, 1);
}

Просмотреть файл

@ -407,52 +407,6 @@ class TestRefinement < Test::Unit::TestCase
end
end
def test_refinements_empty
m = Module.new
assert(m.refinements.empty?)
end
def test_refinements_one
c = Class.new
c_ext = nil
m = Module.new {
refine c do
c_ext = self
end
}
assert_equal({c => c_ext}, m.refinements)
end
def test_refinements_two
c1 = Class.new
c1_ext = nil
c2 = Class.new
c2_ext = nil
m = Module.new {
refine c1 do
c1_ext = self
end
refine c2 do
c2_ext = self
end
}
assert_equal({c1 => c1_ext, c2 => c2_ext}, m.refinements)
end
def test_refinements_duplicate_refine
c = Class.new
c_ext = nil
m = Module.new {
refine c do
c_ext = self
end
refine c do
end
}
assert_equal({c => c_ext}, m.refinements)
end
def test_refine_without_block
c1 = Class.new
e = assert_raise(ArgumentError) {
@ -465,26 +419,13 @@ class TestRefinement < Test::Unit::TestCase
module Inspect
module M
refine Fixnum do
end
Fixnum = refine(Fixnum) {}
end
end
def test_inspect
assert_equal("#<refinement:Fixnum@TestRefinement::Inspect::M>",
Inspect::M.refinements[Fixnum].inspect)
c = Class.new
m = Module.new {
refine String do
end
refine c do
end
}
assert_equal("#<refinement:String@#{m.inspect}>",
m.refinements[String].inspect)
assert_equal("#<refinement:#{c.inspect}@#{m.inspect}>",
m.refinements[c].inspect)
Inspect::M::Fixnum.inspect)
end
def test_using_method_cache