mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Enable refinements at Object#respond_to?
[Feature #15327] [Fix GH-2020] From: osyo-manga <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
633fef6dec
commit
16a642c331
4 changed files with 45 additions and 15 deletions
|
@ -524,21 +524,42 @@ describe "Module#refine" do
|
|||
}.should raise_error(NameError, /undefined method `foo'/)
|
||||
end
|
||||
|
||||
it "is not honored by Kernel#respond_to?" do
|
||||
klass = Class.new
|
||||
refinement = Module.new do
|
||||
refine klass do
|
||||
def foo; end
|
||||
ruby_version_is "" ... "2.6" do
|
||||
it "is not honored by Kernel#respond_to?" do
|
||||
klass = Class.new
|
||||
refinement = Module.new do
|
||||
refine klass do
|
||||
def foo; end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
result = nil
|
||||
Module.new do
|
||||
using refinement
|
||||
result = klass.new.respond_to?(:foo)
|
||||
end
|
||||
result = nil
|
||||
Module.new do
|
||||
using refinement
|
||||
result = klass.new.respond_to?(:foo)
|
||||
end
|
||||
|
||||
result.should == false
|
||||
result.should == false
|
||||
end
|
||||
end
|
||||
|
||||
ruby_version_is "2.6" do
|
||||
it "is honored by Kernel#respond_to?" do
|
||||
klass = Class.new
|
||||
refinement = Module.new do
|
||||
refine klass do
|
||||
def foo; end
|
||||
end
|
||||
end
|
||||
|
||||
result = nil
|
||||
Module.new do
|
||||
using refinement
|
||||
result = klass.new.respond_to?(:foo)
|
||||
end
|
||||
|
||||
result.should == true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue