[ruby/prism] Match more error messages
https://github.com/ruby/prism/commit/0cc3a9d63a
This commit is contained in:
parent
d6c1cc5532
commit
b7597dac93
@ -26,7 +26,7 @@ module Prism
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_errors expected, "module Parent module end", [
|
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]
|
["unexpected 'end', assuming it is closing the parent module definition", 21..24]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
@ -177,7 +177,7 @@ module Prism
|
|||||||
|
|
||||||
def test_incomplete_instance_var_string
|
def test_incomplete_instance_var_string
|
||||||
assert_errors expression('%@#@@#'), '%@#@@#', [
|
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]
|
["unexpected instance variable, expecting end-of-input", 4..5]
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
@ -325,7 +325,7 @@ module Prism
|
|||||||
|
|
||||||
def test_aliasing_global_variable_with_global_number_variable
|
def test_aliasing_global_variable_with_global_number_variable
|
||||||
assert_errors expression("alias $a $1"), "alias $a $1", [
|
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
|
end
|
||||||
|
|
||||||
@ -452,7 +452,7 @@ module Prism
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_errors expected, "def foo;module A;end;end", [
|
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
|
end
|
||||||
|
|
||||||
@ -490,7 +490,7 @@ module Prism
|
|||||||
Location()
|
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
|
def foo
|
||||||
bar do
|
bar do
|
||||||
module Foo;end
|
module Foo;end
|
||||||
@ -505,7 +505,7 @@ module Prism
|
|||||||
def foo;rescue;module A;end;end
|
def foo;rescue;module A;end;end
|
||||||
def foo;ensure;module A;end;end
|
def foo;ensure;module A;end;end
|
||||||
RUBY
|
RUBY
|
||||||
message = "unexpected module definition in a method definition"
|
message = "unexpected module definition in method body"
|
||||||
assert_errors expression(source), source, [
|
assert_errors expression(source), source, [
|
||||||
[message, 14..20],
|
[message, 14..20],
|
||||||
[message, 47..53],
|
[message, 47..53],
|
||||||
@ -541,7 +541,7 @@ module Prism
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert_errors expected, "def foo;class A;end;end", [
|
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
|
end
|
||||||
|
|
||||||
@ -551,7 +551,7 @@ module Prism
|
|||||||
def foo;rescue;class A;end;end
|
def foo;rescue;class A;end;end
|
||||||
def foo;ensure;class A;end;end
|
def foo;ensure;class A;end;end
|
||||||
RUBY
|
RUBY
|
||||||
message = "unexpected class definition in a method definition"
|
message = "unexpected class definition in method body"
|
||||||
assert_errors expression(source), source, [
|
assert_errors expression(source), source, [
|
||||||
[message, 14..19],
|
[message, 14..19],
|
||||||
[message, 46..51],
|
[message, 46..51],
|
||||||
@ -1254,7 +1254,7 @@ module Prism
|
|||||||
|
|
||||||
def test_unterminated_global_variable
|
def test_unterminated_global_variable
|
||||||
assert_errors expression("$"), "$", [
|
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
|
end
|
||||||
|
|
||||||
@ -1438,7 +1438,7 @@ module Prism
|
|||||||
def test_class_name
|
def test_class_name
|
||||||
source = "class 0.X end"
|
source = "class 0.X end"
|
||||||
assert_errors expression(source), source, [
|
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
|
end
|
||||||
|
|
||||||
@ -2060,7 +2060,7 @@ module Prism
|
|||||||
def test_block_arg_and_block
|
def test_block_arg_and_block
|
||||||
source = 'foo(&1) { }'
|
source = 'foo(&1) { }'
|
||||||
assert_errors expression(source), source, [
|
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
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user