Skip to content

Commit 231e965

Browse files
committed
Add tests for error cases on #1791, #1807, and #1810
1 parent 2daf51b commit 231e965

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/prism/errors_test.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,6 +1422,39 @@ def test_symbol_in_hash
14221422
]
14231423
end
14241424

1425+
def test_while_endless_method
1426+
source = "while def f = g do end"
1427+
assert_errors expression(source), source, [
1428+
['Expected a predicate expression for the `while` statement', 22..22],
1429+
['Cannot parse the expression', 22..22],
1430+
['Expected an `end` to close the `while` statement', 22..22]
1431+
]
1432+
end
1433+
1434+
def test_match_plus
1435+
source = <<~RUBY
1436+
a in b + c
1437+
a => b + c
1438+
RUBY
1439+
message1 = 'Expected a newline or semicolon after the statement'
1440+
message2 = 'Cannot parse the expression'
1441+
assert_errors expression(source), source, [
1442+
[message1, 6..6],
1443+
[message2, 6..6],
1444+
[message1, 17..17],
1445+
[message2, 17..17],
1446+
]
1447+
end
1448+
1449+
def test_rational_number_with_exponential_portion
1450+
source = '1e1r; 1e1ri'
1451+
message = 'Expected a newline or semicolon after the statement'
1452+
assert_errors expression(source), source, [
1453+
[message, 3..3],
1454+
[message, 9..9]
1455+
]
1456+
end
1457+
14251458
private
14261459

14271460
def assert_errors(expected, source, errors, compare_ripper: RUBY_ENGINE == "ruby")

0 commit comments

Comments
 (0)