Skip to content

Commit 0cc3a9d

Browse files
committed
Match more error messages
1 parent fa7559d commit 0cc3a9d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/prism/errors_test.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def test_module_name_recoverable
2626
)
2727

2828
assert_errors expected, "module Parent module end", [
29-
["expected a constant name after `module`", 14..20],
29+
["unexpected constant path after `module`; class/module name must be CONSTANT", 14..20],
3030
["unexpected 'end', assuming it is closing the parent module definition", 21..24]
3131
]
3232
end
@@ -177,7 +177,7 @@ def test_unterminated_empty_string
177177

178178
def test_incomplete_instance_var_string
179179
assert_errors expression('%@#@@#'), '%@#@@#', [
180-
["'@#' is not allowed as an instance variable name", 4..5],
180+
["'@' without identifiers is not allowed as an instance variable name", 4..5],
181181
["unexpected instance variable, expecting end-of-input", 4..5]
182182
]
183183
end
@@ -325,7 +325,7 @@ def test_aliasing_non_global_variable_with_global_variable
325325

326326
def test_aliasing_global_variable_with_global_number_variable
327327
assert_errors expression("alias $a $1"), "alias $a $1", [
328-
["invalid argument being passed to `alias`; expected a bare word, symbol, constant, or global variable", 9..11]
328+
["invalid argument being passed to `alias`; can't make alias for the number variables", 9..11]
329329
]
330330
end
331331

@@ -452,7 +452,7 @@ def test_module_definition_in_method_body
452452
)
453453

454454
assert_errors expected, "def foo;module A;end;end", [
455-
["unexpected module definition in a method definition", 8..14]
455+
["unexpected module definition in method body", 8..14]
456456
]
457457
end
458458

@@ -490,7 +490,7 @@ def test_module_definition_in_method_body_within_block
490490
Location()
491491
)
492492

493-
assert_errors expected, <<~RUBY, [["unexpected module definition in a method definition", 21..27]]
493+
assert_errors expected, <<~RUBY, [["unexpected module definition in method body", 21..27]]
494494
def foo
495495
bar do
496496
module Foo;end
@@ -505,7 +505,7 @@ def foo(bar = module A;end);end
505505
def foo;rescue;module A;end;end
506506
def foo;ensure;module A;end;end
507507
RUBY
508-
message = "unexpected module definition in a method definition"
508+
message = "unexpected module definition in method body"
509509
assert_errors expression(source), source, [
510510
[message, 14..20],
511511
[message, 47..53],
@@ -541,7 +541,7 @@ def test_class_definition_in_method_body
541541
)
542542

543543
assert_errors expected, "def foo;class A;end;end", [
544-
["unexpected class definition in a method definition", 8..13]
544+
["unexpected class definition in method body", 8..13]
545545
]
546546
end
547547

@@ -551,7 +551,7 @@ def foo(bar = class A;end);end
551551
def foo;rescue;class A;end;end
552552
def foo;ensure;class A;end;end
553553
RUBY
554-
message = "unexpected class definition in a method definition"
554+
message = "unexpected class definition in method body"
555555
assert_errors expression(source), source, [
556556
[message, 14..19],
557557
[message, 46..51],
@@ -1254,7 +1254,7 @@ def test_invalid_operator_write_dot
12541254

12551255
def test_unterminated_global_variable
12561256
assert_errors expression("$"), "$", [
1257-
["'$' is not allowed as a global variable name", 0..1]
1257+
["'$' without identifiers is not allowed as a global variable name", 0..1]
12581258
]
12591259
end
12601260

@@ -1438,7 +1438,7 @@ def test_parameter_name_ending_with_bang_or_question_mark
14381438
def test_class_name
14391439
source = "class 0.X end"
14401440
assert_errors expression(source), source, [
1441-
["expected a constant name after `class`", 6..9],
1441+
["unexpected constant path after `class`; class/module name must be CONSTANT", 6..9],
14421442
]
14431443
end
14441444

@@ -2060,7 +2060,7 @@ def test_non_assoc_equality
20602060
def test_block_arg_and_block
20612061
source = 'foo(&1) { }'
20622062
assert_errors expression(source), source, [
2063-
['multiple block arguments; only one block is allowed', 8..11]
2063+
["both block arg and actual block given; only one block is allowed", 8..11]
20642064
]
20652065
end
20662066

0 commit comments

Comments
 (0)