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:
mame 2017-12-26 09:04:26 +00:00
Родитель 571e48b744
Коммит 9e717416b4
1 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -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 }