mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* object.c (rb_mod_to_s): Module#{to_s,inspect}, when invoked on
a refinement, returns a string in the format #<refinement:C@M>, 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
This commit is contained in:
parent
a8b3d67e7c
commit
b14e2b4401
4 changed files with 55 additions and 1 deletions
|
@ -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("#<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)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue