diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-07 12:42:48 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-07 12:42:48 +0000 |
commit | 19768b6cacb1319f34944a0dc5e0bbe099d2d18e (patch) | |
tree | dff9cb9190b86c36c642dd25c18f8a8bd777fa23 /test | |
parent | 4722c20661093f5071701941bc2f7b519f2a7283 (diff) | |
download | ruby-19768b6cacb1319f34944a0dc5e0bbe099d2d18e.tar.gz |
* vm_method.c (Init_eval_method): main.public and main.private
should be private.
* proc.c (Init_Proc): main.define_method should be private.
* test/ruby/test_module.rb: related test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_module.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 185c445091..340c37762a 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1597,22 +1597,22 @@ class TestModule < Test::Unit::TestCase assert_raise(NameError){ m.instance_eval { remove_const(:__FOO__) } } end - def test_top_include_is_private - main = eval("self", TOPLEVEL_BINDING) - methods = main.singleton_class.private_instance_methods(false) - assert(methods.include?(:include)) + def test_private_top_methods + assert_top_method_is_private(:include) + assert_top_method_is_private(:public) + assert_top_method_is_private(:private) + assert_top_method_is_private(:define_method) + end - assert_in_out_err([], <<-INPUT, ["true"], []) - module M - end - include M - p singleton_class < M - INPUT + private - assert_in_out_err([], <<-INPUT, [], /private method `include' called for main:Object \(NoMethodError\)/) - module M - end - self.include M + def assert_top_method_is_private(method) + top = eval("self", TOPLEVEL_BINDING) + methods = top.singleton_class.private_instance_methods(false) + assert(methods.include?(method), "#{method} should be private") + + assert_in_out_err([], <<-INPUT, [], /private method `#{method}' called for main:Object \(NoMethodError\)/) + self.#{method} INPUT end end |