summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-26 09:04:26 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-26 09:04:26 +0000
commit9e717416b44d92baf52f9e87d32725454eb3487c (patch)
tree4d067a03b2e199cb1388ed887908f7449eac3ec6 /test
parent571e48b74422f5caa8ff6d91faf7e1a6bf4d2dc1 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_proc.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 68455c1bcc..ff0e5f9775 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -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 }