summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTSUYUSATO Kitsune <make.just.on@gmail.com>2023-11-13 14:42:24 +0900
committergit <svn-admin@ruby-lang.org>2023-11-13 13:34:24 +0000
commitd5c3680a0c29890b85b868afe450d28e392c609e (patch)
tree4a05a9c6683938513475a87979a5d1f80481f080
parent90b49024c0d5fe8fe60942b96dcbd1f610042f1b (diff)
[ruby/prism] Add tests for error cases on #1791, #1807, and #1810
https://github.com/ruby/prism/commit/231e965124
-rw-r--r--test/prism/errors_test.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index ee4736a000..a3631fe45b 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -1422,6 +1422,39 @@ module Prism
]
end
+ def test_while_endless_method
+ source = "while def f = g do end"
+ assert_errors expression(source), source, [
+ ['Expected a predicate expression for the `while` statement', 22..22],
+ ['Cannot parse the expression', 22..22],
+ ['Expected an `end` to close the `while` statement', 22..22]
+ ]
+ end
+
+ def test_match_plus
+ source = <<~RUBY
+ a in b + c
+ a => b + c
+ RUBY
+ message1 = 'Expected a newline or semicolon after the statement'
+ message2 = 'Cannot parse the expression'
+ assert_errors expression(source), source, [
+ [message1, 6..6],
+ [message2, 6..6],
+ [message1, 17..17],
+ [message2, 17..17],
+ ]
+ end
+
+ def test_rational_number_with_exponential_portion
+ source = '1e1r; 1e1ri'
+ message = 'Expected a newline or semicolon after the statement'
+ assert_errors expression(source), source, [
+ [message, 3..3],
+ [message, 9..9]
+ ]
+ end
+
private
def assert_errors(expected, source, errors, compare_ripper: RUBY_ENGINE == "ruby")