diff --git a/ChangeLog b/ChangeLog index 2364d0c2d8..48f8d61e19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Dec 8 22:33:26 2012 Shugo Maeda + + * eval.c: remove Module#refinements. + + * test/ruby/test_refinement.rb: remove tests for Module#refinements. + Sat Dec 8 13:17:55 2012 Shugo Maeda * eval.c (top_using): raise a RuntimeError if using is called in a diff --git a/eval.c b/eval.c index d0dcdddc6b..532bbccc0e 100644 --- a/eval.c +++ b/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); } diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 016aa15f19..a956535f60 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -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("#", - Inspect::M.refinements[Fixnum].inspect) - - c = Class.new - m = Module.new { - refine String do - end - refine c do - end - } - assert_equal("#", - m.refinements[String].inspect) - assert_equal("#", - m.refinements[c].inspect) + Inspect::M::Fixnum.inspect) end def test_using_method_cache