summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEarlopain <14981592+Earlopain@users.noreply.github.com>2026-02-12 16:40:54 +0100
committergit <svn-admin@ruby-lang.org>2026-02-12 15:53:47 +0000
commitfd9dd36dfc38fd818dba0558bacb7c2df9bcdb79 (patch)
tree52d61d0c3d724ce78e7c50bb1489cec3d252c52c /test
parentb5d2c6eeca28f4c640389b006896a8f3f59e7571 (diff)
[ruby/prism] Revert "Fix lexing for unterminated strings/heredocs etc."
This reverts commit https://github.com/ruby/prism/commit/8f35e8ef255b. https://github.com/ruby/prism/commit/ed48f6dbfb
Diffstat (limited to 'test')
-rw-r--r--test/prism/errors/unterminated_heredoc_and_embexpr.txt11
-rw-r--r--test/prism/errors/unterminated_heredoc_and_embexpr_2.txt9
-rw-r--r--test/prism/lex_test.rb53
3 files changed, 3 insertions, 70 deletions
diff --git a/test/prism/errors/unterminated_heredoc_and_embexpr.txt b/test/prism/errors/unterminated_heredoc_and_embexpr.txt
deleted file mode 100644
index bed7fcd24e..0000000000
--- a/test/prism/errors/unterminated_heredoc_and_embexpr.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-<<A+B
- ^ unterminated heredoc; can't find string "A" anywhere before EOF
- ^ unexpected '+', ignoring it
- ^ unterminated heredoc; can't find string "A" anywhere before EOF
-#{C
- ^ unexpected heredoc ending; expected an argument
- ^ unexpected heredoc ending, expecting end-of-input
- ^ unexpected heredoc ending, ignoring it
- ^ unexpected end-of-input, assuming it is closing the parent top level context
-^ expected a `}` to close the embedded expression
-
diff --git a/test/prism/errors/unterminated_heredoc_and_embexpr_2.txt b/test/prism/errors/unterminated_heredoc_and_embexpr_2.txt
deleted file mode 100644
index a03ff1d212..0000000000
--- a/test/prism/errors/unterminated_heredoc_and_embexpr_2.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-<<A+B
- ^ unterminated heredoc; can't find string "A" anywhere before EOF
-#{C + "#{"}
- ^ unterminated string meets end of file
- ^ unexpected end-of-input, assuming it is closing the parent top level context
- ^ expected a `}` to close the embedded expression
- ^ unterminated string; expected a closing delimiter for the interpolated string
- ^ expected a `}` to close the embedded expression
-
diff --git a/test/prism/lex_test.rb b/test/prism/lex_test.rb
index 8ea7ce7e9b..9a9f203c28 100644
--- a/test/prism/lex_test.rb
+++ b/test/prism/lex_test.rb
@@ -48,58 +48,11 @@ module Prism
end
if RUBY_VERSION >= "3.3"
- def test_lex_compat
- source = "foo bar"
- prism = Prism.lex_compat(source, version: "current").value
- ripper = Ripper.lex(source)
+ def test_lex_compare
+ prism = Prism.lex_compat(File.read(__FILE__), version: "current").value
+ ripper = Ripper.lex(File.read(__FILE__))
assert_equal(ripper, prism)
end
end
-
- def test_lex_interpolation_unterminated
- assert_equal(
- %i[STRING_BEGIN EMBEXPR_BEGIN EOF],
- token_types('"#{')
- )
-
- assert_equal(
- %i[STRING_BEGIN EMBEXPR_BEGIN IGNORED_NEWLINE EOF],
- token_types('"#{' + "\n")
- )
- end
-
- def test_lex_interpolation_unterminated_with_content
- # FIXME: Emits EOL twice.
- assert_equal(
- %i[STRING_BEGIN EMBEXPR_BEGIN CONSTANT EOF EOF],
- token_types('"#{C')
- )
-
- assert_equal(
- %i[STRING_BEGIN EMBEXPR_BEGIN CONSTANT NEWLINE EOF],
- token_types('"#{C' + "\n")
- )
- end
-
- def test_lex_heredoc_unterminated
- code = <<~'RUBY'.strip
- <<A+B
- #{C
- RUBY
-
- assert_equal(
- %i[HEREDOC_START EMBEXPR_BEGIN CONSTANT HEREDOC_END PLUS CONSTANT NEWLINE EOF],
- token_types(code)
- )
-
- assert_equal(
- %i[HEREDOC_START EMBEXPR_BEGIN CONSTANT NEWLINE HEREDOC_END PLUS CONSTANT NEWLINE EOF],
- token_types(code + "\n")
- )
- end
-
- def token_types(code)
- Prism.lex(code).value.map { |token, _state| token.type }
- end
end
end