From dafc1f757a80055cee86efd676d1b81366b54565 Mon Sep 17 00:00:00 2001 From: nagachika Date: Thu, 26 Sep 2013 16:22:24 +0000 Subject: merge revision(s) 42980,42981: [Backport #8927] * parse.y (lambda): adjust position to the beginning of the block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_lambda.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/ruby/test_lambda.rb') diff --git a/test/ruby/test_lambda.rb b/test/ruby/test_lambda.rb index 40bd134e2f..175183d847 100644 --- a/test/ruby/test_lambda.rb +++ b/test/ruby/test_lambda.rb @@ -89,4 +89,28 @@ class TestLambdaParameters < Test::Unit::TestCase assert_send([e.backtrace.first, :start_with?, "#{__FILE__}:#{line}:"], bug6151) assert_equal(0, called) end + + def test_do_lambda_source_location + exp_lineno = __LINE__ + 3 + lmd = ->(x, + y, + z) do + # + end + file, lineno = lmd.source_location + assert_match(/^#{ Regexp.quote(__FILE__) }$/, file) + assert_equal(exp_lineno, lineno, "must be at the beginning of the block") + end + + def test_brace_lambda_source_location + exp_lineno = __LINE__ + 3 + lmd = ->(x, + y, + z) { + # + } + file, lineno = lmd.source_location + assert_match(/^#{ Regexp.quote(__FILE__) }$/, file) + assert_equal(exp_lineno, lineno, "must be at the beginning of the block") + end end -- cgit v1.2.3