Skip to content

Commit

Permalink
[ruby/irb] Always add \n at the end of the test input in RubyLex
Browse files Browse the repository at this point in the history
  • Loading branch information
tompng authored and matzbot committed Jun 27, 2023
1 parent 9dd8698 commit eaad44a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/irb/test_ruby_lex.rb
Expand Up @@ -101,7 +101,7 @@ def assert_code_block_open(lines, expected, local_variables: [])

def check_state(lines, 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)
opens = IRB::NestingParser.open_tokens(tokens)
ruby_lex = RubyLex.new(context)
Expand Down Expand Up @@ -791,7 +791,7 @@ def test_should_continue
assert_should_continue(['a;'], false)
assert_should_continue(['<<A', '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; #comment', '', '=begin', 'embdoc', '=end', ''], false)
Expand All @@ -801,13 +801,13 @@ def test_should_continue
def test_code_block_open_with_should_continue
# syntax ok
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
assert_code_block_open(['a+', ''], true)
assert_code_block_open(['a+'], true)

# 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
assert_code_block_open(['@; a'], false)
Expand Down

0 comments on commit eaad44a

Please sign in to comment.