ruby-changes:64272
From: Yusuke <ko1@a...>
Date: Fri, 18 Dec 2020 16:09:32 +0900 (JST)
Subject: [ruby-changes:64272] c4e50b58d1 (master): Revert "Added missing tests for public, private, protected and alias_method"
https://git.ruby-lang.org/ruby.git/commit/?id=c4e50b58d1 From c4e50b58d1e6f030b24faffbc208d3d454d1f433 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Fri, 18 Dec 2020 14:12:15 +0900 Subject: Revert "Added missing tests for public, private, protected and alias_method" This reverts commit e042e8460bb9a63c05f938d51e8c7c5345a6f3a4. diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 037715b..55755a6 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -828,67 +828,6 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L828 assert_equal([:bClass1], BClass.public_instance_methods(false)) end - def test_s_public - o = (c = Class.new(AClass)).new - assert_raise(NoMethodError, /private method/) {o.aClass1} - assert_raise(NoMethodError, /protected method/) {o.aClass2} - c.class_eval {public :aClass1} - assert_equal(:aClass1, o.aClass1) - - o = (c = Class.new(AClass)).new - c.class_eval {public :aClass1, :aClass2} - assert_equal(:aClass1, o.aClass1) - assert_equal(:aClass2, o.aClass2) - - o = AClass.new - assert_equal(:aClass, o.aClass) - assert_raise(NoMethodError, /private method/) {o.aClass1} - assert_raise(NoMethodError, /protected method/) {o.aClass2} - end - - def test_s_private - o = (c = Class.new(AClass)).new - assert_equal(:aClass, o.aClass) - c.class_eval {private :aClass} - assert_raise(NoMethodError, /private method/) {o.aClass} - - o = (c = Class.new(AClass)).new - c.class_eval {private :aClass, :aClass2} - assert_raise(NoMethodError, /private method/) {o.aClass} - assert_raise(NoMethodError, /private method/) {o.aClass2} - - o = AClass.new - assert_equal(:aClass, o.aClass) - assert_raise(NoMethodError, /private method/) {o.aClass1} - assert_raise(NoMethodError, /protected method/) {o.aClass2} - end - - def test_s_protected - aclass = Class.new(AClass) do - def _aClass(o) o.aClass; end - def _aClass1(o) o.aClass1; end - def _aClass2(o) o.aClass2; end - end - - o = (c = Class.new(aclass)).new - assert_equal(:aClass, o.aClass) - c.class_eval {protected :aClass} - assert_raise(NoMethodError, /protected method/) {o.aClass} - assert_equal(:aClass, c.new._aClass(o)) - - o = (c = Class.new(aclass)).new - c.class_eval {protected :aClass, :aClass1} - assert_raise(NoMethodError, /protected method/) {o.aClass} - assert_raise(NoMethodError, /protected method/) {o.aClass1} - assert_equal(:aClass, c.new._aClass(o)) - assert_equal(:aClass1, c.new._aClass1(o)) - - o = AClass.new - assert_equal(:aClass, o.aClass) - assert_raise(NoMethodError, /private method/) {o.aClass1} - assert_raise(NoMethodError, /protected method/) {o.aClass2} - end - def test_s_constants c1 = Module.constants Object.module_eval "WALTER = 99" @@ -1217,18 +1156,6 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1156 end end - def test_alias_method - c = Class.new do - def foo; :foo end - end - o = c.new - assert_respond_to(o, :foo) - assert_not_respond_to(o, :bar) - c.class_eval {alias_method :bar, :foo} - assert_respond_to(o, :bar) - assert_equal(:foo, o.bar) - end - def test_undef c = Class.new assert_raise(NameError) do diff --git a/vm_method.c b/vm_method.c index f0f6580..e2c5bfb 100644 --- a/vm_method.c +++ b/vm_method.c @@ -2004,8 +2004,7 @@ set_method_visibility(VALUE self, int argc, const VALUE *argv, rb_method_visibil https://github.com/ruby/ruby/blob/trunk/vm_method.c#L2004 for (j = 0; j < RARRAY_LEN(v); j++) { check_and_export_method(self, RARRAY_AREF(v, j), visi); } - } - else { + } else { for (i = 0; i < argc; i++) { check_and_export_method(self, argv[i], visi); } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/