summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-14 08:11:00 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-12-14 08:11:00 +0000
commit5a565d5c4df425c9c591099cf750f123d432ba7a (patch)
treeb27ef07942485729d2b018bb2f39f0de9a14ca7a /test/ruby
parent1d7f737553b2d7071fc4e28e4bfaf40778acf9a6 (diff)
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
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_syntax.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb
index ec3af712f4..f9f279d751 100644
--- a/test/ruby/test_syntax.rb
+++ b/test/ruby/test_syntax.rb
@@ -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