1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/irb] follow up the actual line number

https://github.com/ruby/irb/commit/7aed8fe3b1
This commit is contained in:
Nobuhiro IMAI 2020-03-24 15:24:01 +09:00 committed by git
parent 739f9297c5
commit b0fb208218
2 changed files with 25 additions and 1 deletions

View file

@ -223,7 +223,10 @@ class RubyLex
throw :TERM_INPUT if @line == ''
else
@line_no += l.count("\n")
next if l == "\n"
if l == "\n"
@exp_line_no += 1
next
end
@line.concat l
if @code_block_open or @ltype or @continue or @indent > 0
next

View file

@ -572,5 +572,26 @@ module TestIRB
ensure
$VERBOSE = verbose
end
def test_lineno
input = TestInputMethod.new([
"\n",
"__LINE__\n",
"__LINE__\n",
"\n",
"\n",
"__LINE__\n",
])
irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new), input)
out, err = capture_output do
irb.eval_input
end
assert_empty err
assert_pattern_list([
:*, /\b2\n/,
:*, /\b3\n/,
:*, /\b6\n/,
], out)
end
end
end