[ruby/irb] Always add \n at the end of the test input in RubyLex

test
(https://github.com/ruby/irb/pull/614)

https://github.com/ruby/irb/commit/e68c6128aa
This commit is contained in:
tomoya ishida 2023-06-27 19:18:58 +09:00 committed by git
parent 9dd8698597
commit eaad44adb2

View File

@ -101,7 +101,7 @@ module TestIRB
def check_state(lines, local_variables: []) def check_state(lines, local_variables: [])
context = build_context(local_variables) context = build_context(local_variables)
code = lines.join("\n") code = lines.map { |l| "#{l}\n" }.join # code should end with "\n"
tokens = RubyLex.ripper_lex_without_warning(code, context: context) tokens = RubyLex.ripper_lex_without_warning(code, context: context)
opens = IRB::NestingParser.open_tokens(tokens) opens = IRB::NestingParser.open_tokens(tokens)
ruby_lex = RubyLex.new(context) ruby_lex = RubyLex.new(context)
@ -791,7 +791,7 @@ module TestIRB
assert_should_continue(['a;'], false) assert_should_continue(['a;'], false)
assert_should_continue(['<<A', 'A'], false) assert_should_continue(['<<A', 'A'], false)
assert_should_continue(['a...'], false) assert_should_continue(['a...'], false)
assert_should_continue(['a\\', ''], true) assert_should_continue(['a\\'], true)
assert_should_continue(['a.'], true) assert_should_continue(['a.'], true)
assert_should_continue(['a+'], true) assert_should_continue(['a+'], true)
assert_should_continue(['a; #comment', '', '=begin', 'embdoc', '=end', ''], false) assert_should_continue(['a; #comment', '', '=begin', 'embdoc', '=end', ''], false)
@ -801,13 +801,13 @@ module TestIRB
def test_code_block_open_with_should_continue def test_code_block_open_with_should_continue
# syntax ok # syntax ok
assert_code_block_open(['a'], false) # continue: false assert_code_block_open(['a'], false) # continue: false
assert_code_block_open(['a\\', ''], true) # continue: true assert_code_block_open(['a\\'], true) # continue: true
# recoverable syntax error code is not terminated # recoverable syntax error code is not terminated
assert_code_block_open(['a+', ''], true) assert_code_block_open(['a+'], true)
# unrecoverable syntax error code is terminated # unrecoverable syntax error code is terminated
assert_code_block_open(['.; a+', ''], false) assert_code_block_open(['.; a+'], false)
# other syntax error that failed to determine if it is recoverable or not # other syntax error that failed to determine if it is recoverable or not
assert_code_block_open(['@; a'], false) assert_code_block_open(['@; a'], false)