Skip to content

Commit

Permalink
[ruby/prism] Match more error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Apr 1, 2024
1 parent d6c1cc5 commit b7597da
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions test/prism/errors_test.rb
Expand Up @@ -26,7 +26,7 @@ def test_module_name_recoverable
)

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

def test_incomplete_instance_var_string
assert_errors expression('%@#@@#'), '%@#@@#', [
["'@#' is not allowed as an instance variable name", 4..5],
["'@' without identifiers is not allowed as an instance variable name", 4..5],
["unexpected instance variable, expecting end-of-input", 4..5]
]
end
Expand Down Expand Up @@ -325,7 +325,7 @@ def test_aliasing_non_global_variable_with_global_variable

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

Expand Down Expand Up @@ -452,7 +452,7 @@ def test_module_definition_in_method_body
)

assert_errors expected, "def foo;module A;end;end", [
["unexpected module definition in a method definition", 8..14]
["unexpected module definition in method body", 8..14]
]
end

Expand Down Expand Up @@ -490,7 +490,7 @@ def test_module_definition_in_method_body_within_block
Location()
)

assert_errors expected, <<~RUBY, [["unexpected module definition in a method definition", 21..27]]
assert_errors expected, <<~RUBY, [["unexpected module definition in method body", 21..27]]
def foo
bar do
module Foo;end
Expand All @@ -505,7 +505,7 @@ def foo(bar = module A;end);end
def foo;rescue;module A;end;end
def foo;ensure;module A;end;end
RUBY
message = "unexpected module definition in a method definition"
message = "unexpected module definition in method body"
assert_errors expression(source), source, [
[message, 14..20],
[message, 47..53],
Expand Down Expand Up @@ -541,7 +541,7 @@ def test_class_definition_in_method_body
)

assert_errors expected, "def foo;class A;end;end", [
["unexpected class definition in a method definition", 8..13]
["unexpected class definition in method body", 8..13]
]
end

Expand All @@ -551,7 +551,7 @@ def foo(bar = class A;end);end
def foo;rescue;class A;end;end
def foo;ensure;class A;end;end
RUBY
message = "unexpected class definition in a method definition"
message = "unexpected class definition in method body"
assert_errors expression(source), source, [
[message, 14..19],
[message, 46..51],
Expand Down Expand Up @@ -1254,7 +1254,7 @@ def test_invalid_operator_write_dot

def test_unterminated_global_variable
assert_errors expression("$"), "$", [
["'$' is not allowed as a global variable name", 0..1]
["'$' without identifiers is not allowed as a global variable name", 0..1]
]
end

Expand Down Expand Up @@ -1438,7 +1438,7 @@ def test_parameter_name_ending_with_bang_or_question_mark
def test_class_name
source = "class 0.X end"
assert_errors expression(source), source, [
["expected a constant name after `class`", 6..9],
["unexpected constant path after `class`; class/module name must be CONSTANT", 6..9],
]
end

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

Expand Down

0 comments on commit b7597da

Please sign in to comment.