File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments