summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2022-03-10 12:19:40 -0800
committerJohn Hawthorn <john@hawthorn.email>2022-03-11 10:36:19 -0800
commit83fabfccf5d45312325bab83de2cf62ea54fa020 (patch)
tree739f3e6256c8e1cbb122b7e9fd1ed5294083204c /test
parent4d8f76286beefbb8f7fba2479f6d0a0b4a47304c (diff)
Add test for protected methods on module included
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5642
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_module.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index e744121718..6bbe168348 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -756,6 +756,25 @@ class TestModule < Test::Unit::TestCase
assert_equal([:m1, :m0, :m, :sc, :m1, :m0, :c], sc.new.m)
end
+ def test_protected_include_into_included_module
+ m1 = Module.new do
+ def other_foo(other)
+ other.foo
+ end
+
+ protected
+ def foo
+ :ok
+ end
+ end
+ m2 = Module.new
+ c1 = Class.new { include m2 }
+ c2 = Class.new { include m2 }
+ m2.include(m1)
+
+ assert_equal :ok, c1.new.other_foo(c2.new)
+ end
+
def test_instance_methods
assert_equal([:user, :user2], User.instance_methods(false).sort)
assert_equal([:user, :user2, :mixin].sort, User.instance_methods(true).sort)