[前][次][番号順一覧][スレッド一覧]

ruby-changes:26218

From: shugo <ko1@a...>
Date: Sat, 8 Dec 2012 22:37:42 +0900 (JST)
Subject: [ruby-changes:26218] shugo:r38275 (trunk): * eval.c: remove Module#refinements.

shugo	2012-12-08 22:35:15 +0900 (Sat, 08 Dec 2012)

  New Revision: 38275

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38275

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

  Modified files:
    trunk/ChangeLog
    trunk/eval.c
    trunk/test/ruby/test_refinement.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38274)
+++ ChangeLog	(revision 38275)
@@ -1,3 +1,9 @@
+Sat Dec  8 22:33:26 2012  Shugo Maeda  <shugo@r...>
+
+	* 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@r...>
 
 	* eval.c (top_using): raise a RuntimeError if using is called in a
Index: eval.c
===================================================================
--- eval.c	(revision 38274)
+++ eval.c	(revision 38275)
@@ -1237,37 +1237,6 @@
     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 @@
 {
     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);
 }
Index: test/ruby/test_refinement.rb
===================================================================
--- test/ruby/test_refinement.rb	(revision 38274)
+++ test/ruby/test_refinement.rb	(revision 38275)
@@ -407,52 +407,6 @@
     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 @@
 
   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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]