diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-08 13:35:15 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-08 13:35:15 +0000 |
commit | 4363d0765b802e0f8322fceeb282aa1c0d3f3e8b (patch) | |
tree | 6e523d22f67402f8f0ead861e57fad68b92f4722 | |
parent | bdb8607cb7549f8555fed781392231ead86d984b (diff) |
* 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
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | eval.c | 32 | ||||
-rw-r--r-- | test/ruby/test_refinement.rb | 63 |
3 files changed, 8 insertions, 93 deletions
@@ -1,3 +1,9 @@ +Sat Dec 8 22:33:26 2012 Shugo Maeda <[email protected]> + + * eval.c: remove Module#refinements. + + * test/ruby/test_refinement.rb: remove tests for Module#refinements. + Sat Dec 8 13:17:55 2012 Shugo Maeda <[email protected]> * eval.c (top_using): raise a RuntimeError if using is called in a @@ -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("#<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 |