From b14e2b4401db4746cc45ae9e4ce6350f7594f84f Mon Sep 17 00:00:00 2001 From: shugo Date: Fri, 2 Nov 2012 08:53:06 +0000 Subject: * object.c (rb_mod_to_s): Module#{to_s,inspect}, when invoked on a refinement, returns a string in the format #, where C is a refined class and M is a module at which the refinemet is defined. * eval.c (rb_mod_refine): store information on a refinement for the above change. * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_refinement.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test') diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 4a0e6d1327..eee66105b1 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -622,4 +622,28 @@ class TestRefinement < Test::Unit::TestCase def test_symbol_to_proc assert_equal("foo", SymbolToProc::M.call_foo) end + + module Inspect + module M + refine Fixnum do + end + 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) + end end -- cgit v1.2.3