Revert "Added missing tests for public, private, protected and alias_method"

This reverts commit e042e8460b.
This commit is contained in:
Yusuke Endoh 2020-12-18 14:12:15 +09:00
Родитель 0a60ba923e
Коммит c4e50b58d1
2 изменённых файлов: 1 добавлений и 75 удалений

Просмотреть файл

@ -828,67 +828,6 @@ class TestModule < Test::Unit::TestCase
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
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

Просмотреть файл

@ -2004,8 +2004,7 @@ set_method_visibility(VALUE self, int argc, const VALUE *argv, rb_method_visibil
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);
}