File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1422,6 +1422,39 @@ def test_symbol_in_hash
1422
1422
]
1423
1423
end
1424
1424
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
+
1425
1458
private
1426
1459
1427
1460
def assert_errors ( expected , source , errors , compare_ripper : RUBY_ENGINE == "ruby" )
You can’t perform that action at this time.
0 commit comments