diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2023-09-15 11:36:06 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-09-15 22:24:38 +0000 |
| commit | d2c75bb9372cf4f2e63082ca493c9bdf74280c3d (patch) | |
| tree | 62b0844cbafb7e87d6b939155f0084a43f6d6578 /test | |
| parent | ffe77c022ca02717576b9d272c43baf8ec81083d (diff) | |
[ruby/yarp] Handle missing terminators in parenthesized expression
https://github.com/ruby/yarp/commit/a8b54e8ed0
Diffstat (limited to 'test')
| -rw-r--r-- | test/yarp/errors_test.rb | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/test/yarp/errors_test.rb b/test/yarp/errors_test.rb index d73e6c6ff2..d67b5e411d 100644 --- a/test/yarp/errors_test.rb +++ b/test/yarp/errors_test.rb @@ -167,11 +167,18 @@ module YARP def test_unterminated_parenthesized_expression assert_errors expression('(1 + 2'), '(1 + 2', [ + ["Expected a newline or semicolon after the statement", 6..6], ["Cannot parse the expression", 6..6], ["Expected a matching `)`", 6..6] ] end + def test_missing_terminator_in_parentheses + assert_error_messages "(0 0)", [ + "Expected a newline or semicolon after the statement" + ] + end + def test_unterminated_argument_expression assert_errors expression('a %'), 'a %', [ ["Invalid `%` token", 2..3], @@ -187,6 +194,7 @@ module YARP def test_1_2_3 assert_errors expression("(1, 2, 3)"), "(1, 2, 3)", [ + ["Expected a newline or semicolon after the statement", 2..2], ["Cannot parse the expression", 2..2], ["Expected a matching `)`", 2..2], ["Expected a newline or semicolon after the statement", 2..2], @@ -194,16 +202,17 @@ module YARP ["Expected a newline or semicolon after the statement", 5..5], ["Cannot parse the expression", 5..5], ["Expected a newline or semicolon after the statement", 8..8], - ["Cannot parse the expression", 8..8], + ["Cannot parse the expression", 8..8] ] end def test_return_1_2_3 assert_error_messages "return(1, 2, 3)", [ + "Expected a newline or semicolon after the statement", "Cannot parse the expression", "Expected a matching `)`", "Expected a newline or semicolon after the statement", - "Cannot parse the expression", + "Cannot parse the expression" ] end @@ -215,10 +224,11 @@ module YARP def test_next_1_2_3 assert_errors expression("next(1, 2, 3)"), "next(1, 2, 3)", [ + ["Expected a newline or semicolon after the statement", 6..6], ["Cannot parse the expression", 6..6], ["Expected a matching `)`", 6..6], ["Expected a newline or semicolon after the statement", 12..12], - ["Cannot parse the expression", 12..12], + ["Cannot parse the expression", 12..12] ] end @@ -230,10 +240,11 @@ module YARP def test_break_1_2_3 assert_errors expression("break(1, 2, 3)"), "break(1, 2, 3)", [ + ["Expected a newline or semicolon after the statement", 7..7], ["Cannot parse the expression", 7..7], ["Expected a matching `)`", 7..7], ["Expected a newline or semicolon after the statement", 13..13], - ["Cannot parse the expression", 13..13], + ["Cannot parse the expression", 13..13] ] end |
