aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_defined.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-03 23:05:55 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-04 02:12:57 +0900
commit8340c773e54feb399c9fab322e3ff6dd578ac04d (patch)
treebea30e9d8fcdeaccb4a2212f695cc4edef3af9be /test/ruby/test_defined.rb
parent3ced77a82a966998951b7c62b135ef0105f73c36 (diff)
downloadruby-8340c773e54feb399c9fab322e3ff6dd578ac04d.tar.gz
Properly resolve refinements in defined? on method call [Bug #16932]
Diffstat (limited to 'test/ruby/test_defined.rb')
-rw-r--r--test/ruby/test_defined.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb
index e1571d5714..6ad4854b98 100644
--- a/test/ruby/test_defined.rb
+++ b/test/ruby/test_defined.rb
@@ -301,4 +301,32 @@ class TestDefined < Test::Unit::TestCase
def test_top_level_constant_not_defined
assert_nil(defined?(TestDefined::Object))
end
+
+ class RefinedClass
+ end
+
+ module RefiningModule
+ refine RefinedClass do
+ def pub
+ end
+ end
+
+ def self.call_without_using(x = RefinedClass.new)
+ defined?(x.pub)
+ end
+
+ using self
+
+ def self.call_with_using(x = RefinedClass.new)
+ defined?(x.pub)
+ end
+ end
+
+ def test_defined_refined_call_without_using
+ assert(!RefiningModule.call_without_using, "refined public method without using")
+ end
+
+ def test_defined_refined_call_with_using
+ assert(RefiningModule.call_with_using, "refined public method with using")
+ end
end