summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-03 23:06:06 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-04 02:12:57 +0900
commit184f78314e98cab63e7503cead4a4e99bd132a08 (patch)
tree97ba75dd05fc557a30ec400627980b9385f66ab2 /test
parent8340c773e54feb399c9fab322e3ff6dd578ac04d (diff)
Properly resolve refinements in defined? on private call [Bug #16932]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3180
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_defined.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb
index 6ad4854b98..b22db700da 100644
--- a/test/ruby/test_defined.rb
+++ b/test/ruby/test_defined.rb
@@ -309,24 +309,45 @@ class TestDefined < Test::Unit::TestCase
refine RefinedClass do
def pub
end
+
+ private
+
+ def priv
+ end
end
def self.call_without_using(x = RefinedClass.new)
defined?(x.pub)
end
+ def self.vcall_without_using(x = RefinedClass.new)
+ x.instance_eval {defined?(priv)}
+ end
+
using self
def self.call_with_using(x = RefinedClass.new)
defined?(x.pub)
end
+
+ def self.vcall_with_using(x = RefinedClass.new)
+ x.instance_eval {defined?(priv)}
+ end
end
def test_defined_refined_call_without_using
assert(!RefiningModule.call_without_using, "refined public method without using")
end
+ def test_defined_refined_vcall_without_using
+ assert(!RefiningModule.vcall_without_using, "refined private method without using")
+ end
+
def test_defined_refined_call_with_using
assert(RefiningModule.call_with_using, "refined public method with using")
end
+
+ def test_defined_refined_vcall_with_using
+ assert(RefiningModule.vcall_with_using, "refined private method with using")
+ end
end