summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-02 17:07:41 +0900
committernagachika <nagachika@ruby-lang.org>2020-08-01 17:17:01 +0900
commit315f1ee8a80680fd7aff5fa27abfd965d1906809 (patch)
tree5baeb93e4849813f0f516182dc2dcde7fb089b38
parent171d4c512b1497178b39db32b255eb521560d78c (diff)
Split test_defined_method
-rw-r--r--test/ruby/test_defined.rb23
1 files changed, 22 insertions, 1 deletions
diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb
index 6a2db303e9..387472a62d 100644
--- a/test/ruby/test_defined.rb
+++ b/test/ruby/test_defined.rb
@@ -42,21 +42,42 @@ class TestDefined < Test::Unit::TestCase
assert(defined?(File::Constants)) # nested constant
end
- def test_defined_method
+ def test_defined_public_method
assert(defined?(Object.new)) # method
assert(defined?(Object::new)) # method
+ end
+
+ def test_defined_private_method
assert(!defined?(Object.print)) # private method
+ end
+
+ def test_defined_operator
assert(defined?(1 == 2)) # operator expression
+ end
+
+ def test_defined_protected_method
f = Foo.new
assert_nil(defined?(f.foo)) # protected method
f.bar(f) { |v| assert(v) }
+ end
+
+ def test_defined_undefined_method
+ f = Foo.new
assert_nil(defined?(f.quux)) # undefined method
+ end
+
+ def test_defined_undefined_argument
+ f = Foo.new
assert_nil(defined?(f.baz(x))) # undefined argument
x = 0
assert(defined?(f.baz(x)))
assert_nil(defined?(f.quux(x)))
assert(defined?(print(x)))
assert_nil(defined?(quux(x)))
+ end
+
+ def test_defined_attrasgn
+ f = Foo.new
assert(defined?(f.attr = 1))
f.attrasgn_test { |v| assert(v) }
end