mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 12:33:56 +02:00
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/trunk@66938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dd4fdb32bd
commit
7fa16fd962
2 changed files with 11 additions and 1 deletions
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue