diff --git a/test/t/module.rb b/test/t/module.rb index c5d26df8a..7a6b895c8 100644 --- a/test/t/module.rb +++ b/test/t/module.rb @@ -786,6 +786,47 @@ assert('clone Module') do assert_true(B.new.foo) end +assert('method visibility') do + class CallTypeTest + def test_private(&block) + func(&block) + end + def test_protected(&block) + self.func(&block) + end + private + def func + yield + end + end + + v = CallTypeTest.new + + assert_raise(NoMethodError) { v.func { :test } } + assert_equal :test, v.test_private { :test } + + class CallTypeTest + protected :func + end + + assert_raise(NoMethodError) { v.func { :test } } + assert_equal :test, v.test_protected { :test } + assert_equal :test, v.test_private { :test } + + class CallTypeTest + public def public_func + :test + end + + public :func + end + + assert_equal :test, v.public_func + assert_equal :test, v.func { :test } + assert_equal :test, v.test_protected { :test } + assert_equal :test, v.test_private { :test } +end + assert('Module#module_function') do module M def modfunc; end