ruby-changes:61451
From: Nobuyoshi <ko1@a...>
Date: Tue, 2 Jun 2020 19:06:33 +0900 (JST)
Subject: [ruby-changes:61451] c53aebb1d2 (master): Split test_defined_method
https://git.ruby-lang.org/ruby.git/commit/?id=c53aebb1d2 From c53aebb1d2eb5afbb18f9b3db9f9c956a463a4e1 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 2 Jun 2020 17:07:41 +0900 Subject: Split test_defined_method diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index 6a2db30..387472a 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -42,21 +42,42 @@ class TestDefined < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_defined.rb#L42 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/