mirror of
https://github.com/ruby/ruby.git
synced 2025-09-23 12:33:56 +02:00
Module#constant_source_location [Feature #10771]
This commit is contained in:
parent
5084233b88
commit
9384383019
4 changed files with 176 additions and 0 deletions
|
@ -2375,6 +2375,23 @@ class TestModule < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
ConstLocation = [__FILE__, __LINE__]
|
||||
|
||||
def test_const_source_location
|
||||
assert_equal(ConstLocation, self.class.const_source_location(:ConstLocation))
|
||||
assert_equal(ConstLocation, self.class.const_source_location("ConstLocation"))
|
||||
assert_equal(ConstLocation, Object.const_source_location("#{self.class.name}::ConstLocation"))
|
||||
assert_raise(TypeError) {
|
||||
self.class.const_source_location(nil)
|
||||
}
|
||||
assert_raise_with_message(NameError, /wrong constant name/) {
|
||||
self.class.const_source_location("xxx")
|
||||
}
|
||||
assert_raise_with_message(TypeError, %r'does not refer to class/module') {
|
||||
self.class.const_source_location("ConstLocation::FILE")
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def assert_top_method_is_private(method)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue