зеркало из https://github.com/github/ruby.git
test/ruby/test_proc.rb: Add a test for Binding#source_location
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
571e48b744
Коммит
9e717416b4
|
@ -397,6 +397,21 @@ class TestProc < Test::Unit::TestCase
|
|||
assert_equal([1, 2, 3], b.eval("[x, y, z]"))
|
||||
end
|
||||
|
||||
def test_binding_source_location
|
||||
b, expected_location = binding, [__FILE__, __LINE__]
|
||||
assert_equal(expected_location, b.source_location)
|
||||
|
||||
file, lineno = method(:source_location_test).to_proc.binding.source_location
|
||||
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
|
||||
assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
|
||||
end
|
||||
|
||||
def test_source_location
|
||||
file, lineno = method(:source_location_test).source_location
|
||||
assert_match(/^#{ Regexp.quote(__FILE__) }$/, file)
|
||||
assert_equal(@@line_of_source_location_test, lineno, 'Bug #2427')
|
||||
end
|
||||
|
||||
def test_proc_lambda
|
||||
assert_raise(ArgumentError) { proc }
|
||||
assert_raise(ArgumentError) { lambda }
|
||||
|
|
Загрузка…
Ссылка в новой задаче