diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-06-03 23:05:55 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-06-04 02:12:57 +0900 |
commit | 8340c773e54feb399c9fab322e3ff6dd578ac04d (patch) | |
tree | bea30e9d8fcdeaccb4a2212f695cc4edef3af9be /test/ruby/test_defined.rb | |
parent | 3ced77a82a966998951b7c62b135ef0105f73c36 (diff) |
Properly resolve refinements in defined? on method call [Bug #16932]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3180
Diffstat (limited to 'test/ruby/test_defined.rb')
-rw-r--r-- | test/ruby/test_defined.rb | 28 |
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 |