diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-11-17 21:17:19 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-11-20 16:04:45 +0900 |
| commit | fac2498e0299f13dffe4f09a7dd7657fb49bf643 (patch) | |
| tree | ad3780bc4d89b0f430d9149dce7a409794d89246 /test/ruby | |
| parent | 4b899f91647b7da1174492f891de3d6ee8128458 (diff) | |
[Bug #11213] let defined?(super) call respond_to_missing?
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3777
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_defined.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index b22db700da..87f02055ab 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -302,6 +302,39 @@ class TestDefined < Test::Unit::TestCase assert_nil(defined?(TestDefined::Object)) end + def test_super_with_method_missing + c0 = EnvUtil.labeled_class("C0") do + attr_reader :calls + + def initialize + @calls = [] + end + + def method_missing(*args) + @calls << [:method_missing, *args] + end + + def respond_to_missing?(*args) + @calls << [:respond_to_missing?, *args] + true + end + end + + c1 = EnvUtil.labeled_class("C1", c0) do + def foo + super + defined?(super) + end + end + + c = c1.new + assert_not_nil(c.foo) + assert_equal([ + [:method_missing, :foo], + [:respond_to_missing?, :foo, true], + ], c.calls) + end + class RefinedClass end |
