From 9e717416b44d92baf52f9e87d32725454eb3487c Mon Sep 17 00:00:00 2001 From: mame Date: Tue, 26 Dec 2017 09:04:26 +0000 Subject: 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 --- test/ruby/test_proc.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test') 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 } -- cgit v1.2.3