Skip to content

Commit 3c4b30a

Browse files
committed
Add test
1 parent 955a9cb commit 3c4b30a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/rbs/parser_test.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,27 @@ def test_parse_method_type
689689
end
690690
end
691691

692+
def test_parse_method_type__require_eof
693+
RBS::Parser.parse_method_type(buffer("-> Foo extra input")).tap do |method_type|
694+
assert_instance_of RBS::MethodType, method_type
695+
assert_equal "-> Foo", method_type.location.source
696+
end
697+
698+
RBS::Parser.parse_method_type(buffer("-> Foo extra input")).tap do |method_type|
699+
assert_instance_of RBS::MethodType, method_type
700+
assert_equal "-> Foo", method_type.location.source
701+
end
702+
703+
assert_raises RBS::ParsingError do
704+
RBS::Parser.parse_method_type(buffer("-> Foo extra input"), require_eof: true)
705+
end.tap do |exn|
706+
assert_equal(
707+
"test.rbs:1:7...1:12: Syntax error: expected a token `pEOF`, token=`extra` (tLIDENT)",
708+
exn.message
709+
)
710+
end
711+
end
712+
692713
def test_duplicate_keyword
693714
RBS::Parser.parse_method_type(buffer("(top foo, foo: top) -> void")).tap do |method_type|
694715
assert_equal "top foo, foo: top", method_type.type.param_to_s

0 commit comments

Comments
 (0)