@@ -455,4 +455,38 @@ def test_parse__param_type__skip
455455 assert_nil annot . comment_location
456456 end
457457 end
458+
459+ def test_parse__block_type_annotation
460+ Parser . parse_inline_leading_annotation ( "@rbs &block: () [self: String] -> void" , 0 ...) . tap do |annot |
461+ assert_instance_of AST ::Ruby ::Annotations ::BlockParamTypeAnnotation , annot
462+ assert_equal "@rbs &block: () [self: String] -> void" , annot . location . source
463+ assert_equal "@rbs" , annot . prefix_location . source
464+ assert_equal "&" , annot . ampersand_location . source
465+ assert_equal "block" , annot . name_location . source
466+ assert_equal ":" , annot . colon_location . source
467+ assert_nil annot . question_location
468+ assert_equal "() [self: String] -> void" , annot . type_location . source
469+ assert_instance_of Types ::Function , annot . type
470+ assert_nil annot . comment_location
471+ assert_equal :block , annot . name
472+ assert_equal false , annot . optional?
473+ assert_equal true , annot . required?
474+ end
475+
476+ Parser . parse_inline_leading_annotation ( "@rbs &: ? (?) -> void" , 0 ...) . tap do |annot |
477+ assert_instance_of AST ::Ruby ::Annotations ::BlockParamTypeAnnotation , annot
478+ assert_equal "@rbs &: ? (?) -> void" , annot . location . source
479+ assert_equal "@rbs" , annot . prefix_location . source
480+ assert_equal "&" , annot . ampersand_location . source
481+ assert_nil annot . name_location
482+ assert_equal ":" , annot . colon_location . source
483+ assert_equal "?" , annot . question_location . source
484+ assert_equal "(?) -> void" , annot . type_location . source
485+ assert_instance_of Types ::UntypedFunction , annot . type
486+ assert_nil annot . comment_location
487+ assert_nil annot . name
488+ assert_equal true , annot . optional?
489+ assert_equal false , annot . required?
490+ end
491+ end
458492end
0 commit comments