1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add test for protected methods on module included

This commit is contained in:
John Hawthorn 2022-03-10 12:19:40 -08:00
parent 4d8f76286b
commit 83fabfccf5
Notes: git 2022-03-12 03:36:40 +09:00

View file

@ -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)