Line number in backtrace[0] of exceptions caused by undefined variable does not
match (C)Ruby 1.8.6
---------------------------------------------------------------------------------------------------
Key: JRUBY-3826
URL: http://jira.codehaus.org/browse/JRUBY-3826
Project: JRuby
Issue Type: Bug
Components: Interpreter
Affects Versions: JRuby 1.3.1
Environment: JRuby 1.3.1, Ruby 1.8.6
Reporter: Gary S. Weaver
Attachments: test_line_number_in_error.rb
We were able to reproduce related JRuby 1.3.1 bugs in 3/4 tests below.
Running the same tests in (C)Ruby 1.8.6 passed, so it is definitely a JRuby
1.3.1 issue.
The specific bug you mentioned is tested below in the test named:
test_line_number_in_error_for_undefined_variable_called_outside_eval
Create a file named 'test_line_number_in_error.rb' and copy and paste
the following into it (please adjust it as needed, but don't change content if
possible, because it will alter two of the 4 line numbers embedded in the
tests):
{code}
---start copy/paste---
require 'test/unit'
# tests submitted by Jim Wood and Gary S. Weaver 7-21-2009
# issue and code to reproduce submitted by R. Mark Volkmann
# PLEASE DO NOT CHANGE ANYTHING IN THIS FILE.
# SOME TESTS ARE LINE-NUMBER DEPENDENT.
class LineNumberInErrorTest < Test::Unit::TestCase
def
test_line_number_in_error_for_undefined_variable_called_by_function_in_eval
begin
cause_an_interpreter_error_with_undefined_variable_called_by_function_in_eval
rescue StandardError => e
msg = e.backtrace[0]
assert msg.include?(':19:'), "backtrace[0] contained wrong line number:
'#{msg}'"
end
end
def
cause_an_interpreter_error_with_undefined_variable_called_by_function_in_eval
eval <<-EOS
def foo
bar = baz
end
foo
EOS
end
def test_line_number_in_error_for_undefined_variable_in_function_in_eval
# test submitted by Gary S. Weaver 7-21-2009
# issue and code to reproduce submitted by R. Mark Volkmann
begin
cause_an_interpreter_error_with_undefined_variable_in_function_in_eval
rescue StandardError => e
msg = e.backtrace[0]
assert msg.include?(':2:'), "backtrace[0] contained wrong line number:
'#{msg}'"
end
end
def cause_an_interpreter_error_with_undefined_variable_in_function_in_eval
eval <<-EOS
def foo
bar = baz
end
EOS
end
def test_line_number_in_error_for_undefined_variable_called_by_eval_in_eval
# test submitted by Gary S. Weaver 7-21-2009
# issue and code to reproduce submitted by R. Mark Volkmann
begin
cause_an_interpreter_error_with_undefined_variable_called_by_eval_in_eval
rescue StandardError => e
msg = e.backtrace[0]
assert msg.include?(':59:'), "backtrace[0] contained wrong line number:
'#{msg}'"
end
end
def cause_an_interpreter_error_with_undefined_variable_called_by_eval_in_eval
eval <<-EOS
def foo
bar = baz
end
eval 'foo'
EOS
end
def test_line_number_in_error_for_undefined_variable_called_outside_eval
# test submitted by Gary S. Weaver 7-21-2009
# issue and code to reproduce submitted by R. Mark Volkmann
begin
cause_an_interpreter_error_with_undefined_variable_called_outside_eval
rescue StandardError => e
msg = e.backtrace[0]
assert msg.include?(':2:'), "backtrace[0] contained wrong line number:
'#{msg}'"
end
end
def cause_an_interpreter_error_with_undefined_variable_called_outside_eval
eval <<-EOS
def foo
bar = baz
end
EOS
foo
end
end
---end copy/paste---
{code}
Here is the comparison of execution in JRuby vs. Ruby:
{code}
Loaded suite /path/to/jruby/test/test_line_number_in_error
Started
FFF.
Finished in 0.096 seconds.
1) Failure:
test_line_number_in_error_for_undefined_variable_called_by_eval_in_eval(LineNumberInErrorTest)
[/path/to/jruby/test/test_line_number_in_error.rb:54]:
backtrace[0] contained wrong line number: '(eval):1:in
`cause_an_interpreter_error_with_undefined_variable_called_by_eval_in_eval''.
<false> is not true.
2) Failure:
test_line_number_in_error_for_undefined_variable_called_by_function_in_eval(LineNumberInErrorTest)
[/path/to/jruby/test/test_line_number_in_error.rb:14]:
backtrace[0] contained wrong line number: '(eval):5:in
`cause_an_interpreter_error_with_undefined_variable_called_by_function_in_eval''.
<false> is not true.
3) Failure:
test_line_number_in_error_for_undefined_variable_called_outside_eval(LineNumberInErrorTest)
[/path/to/jruby/test/test_line_number_in_error.rb:75]:
backtrace[0] contained wrong line number:
'/path/to/jruby/test/test_line_number_in_error.rb:86:in
`cause_an_interpreter_error_with_undefined_variable_called_outside_eval''.
<false> is not true.
4 tests, 3 assertions, 3 failures, 0 errors
{code}
{code}
$ ruby test/test_line_number_in_error.rb
Loaded suite test/test_line_number_in_error
Started
....
Finished in 0.000526 seconds.
4 tests, 3 assertions, 0 failures, 0 errors
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email