mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: fix line number
* parse.y (parser_params): parser_tokline to track the line number at which token started. [ruby-dev:46737] [Bug #7559] * parse.y (fcall): operation with starting line number. * parse.y (command, primary, method_call): point method name line. * parse.y (gettable_gen): return token line for __LINE__. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1d7f737553
commit
5a565d5c4d
3 changed files with 73 additions and 20 deletions
|
@ -194,6 +194,36 @@ class TestSyntax < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
Bug7559 = '[ruby-dev:46737]'
|
||||
|
||||
def test_lineno_command_call_quote
|
||||
expected = __LINE__ + 1
|
||||
actual = caller_lineno "a
|
||||
b
|
||||
c
|
||||
d
|
||||
e"
|
||||
assert_equal(expected, actual, "#{Bug7559}: ")
|
||||
end
|
||||
|
||||
def test_lineno_after_heredoc
|
||||
bug7559 = '[ruby-dev:46737]'
|
||||
expected, _, actual = __LINE__, <<eom, __LINE__
|
||||
a
|
||||
b
|
||||
c
|
||||
d
|
||||
eom
|
||||
assert_equal(expected, actual, bug7559)
|
||||
end
|
||||
|
||||
def test_lineno_operation_brace_block
|
||||
expected = __LINE__ + 1
|
||||
actual = caller_lineno\
|
||||
{}
|
||||
assert_equal(expected, actual)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def not_label(x) @result = x; @not_label ||= nil end
|
||||
|
@ -227,4 +257,8 @@ class TestSyntax < Test::Unit::TestCase
|
|||
const_set(:SCRIPT_LINES__, script_lines) if script_lines
|
||||
end
|
||||
end
|
||||
|
||||
def caller_lineno(*)
|
||||
caller_locations(1, 1)[0].lineno
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue