diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-29 04:39:32 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-29 04:39:32 +0000 |
commit | bf8cc37b467e1d372e1b01b4d25e9ef6f8cc927f (patch) | |
tree | 9db21db14ecc251eab561523240bca36569d3575 /test | |
parent | df7ac8afa196bb9d1836fc6d188c831b27b8e507 (diff) |
merge revision(s) 66938: [Backport #15488]
Fix `Module#const_defined?` on inherited constants
[Fix GH-2061]
From: manga_osyo <manga.osyo@gmail.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@66939 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_module.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 4ca0e09277..9e9eb13fba 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -338,6 +338,17 @@ class TestModule < Test::Unit::TestCase assert_raise(NameError) {self.class.const_defined?(const)} end + def test_nested_defined_inheritance + assert_send([Object, :const_defined?, [self.class.name, 'User', 'MIXIN'].join('::')]) + assert_send([self.class, :const_defined?, 'User::MIXIN']) + assert_send([Object, :const_defined?, 'File::SEEK_SET']) + + # const_defined? with `false` + assert_not_send([Object, :const_defined?, [self.class.name, 'User', 'MIXIN'].join('::'), false]) + assert_not_send([self.class, :const_defined?, 'User::MIXIN', false]) + assert_not_send([Object, :const_defined?, 'File::SEEK_SET', false]) + end + def test_nested_defined_bad_class assert_raise(TypeError) do self.class.const_defined?('User::USER::Foo') |