@@ -633,3 +633,44 @@ TEST(DeclSyntaxTests, FunctionDeclWithAPIs) {
633633TEST (DeclSyntaxTests, FunctionDeclBuilderAPIs) {
634634
635635}
636+
637+ #pragma mark - parameterized protocol-decl
638+
639+ TEST (DeclSyntaxTests, ProtocolMakeAPIs) {
640+ RC<SyntaxArena> Arena = SyntaxArena::make ();
641+ SyntaxFactory Factory (Arena);
642+ {
643+ SmallString<1 > Scratch;
644+ llvm::raw_svector_ostream OS (Scratch);
645+ Factory.makeBlankProtocolDecl ().print (OS);
646+ ASSERT_EQ (OS.str ().str (), " " );
647+ }
648+ {
649+ SmallString<64 > Scratch;
650+ llvm::raw_svector_ostream OS (Scratch);
651+ auto Protocol = Factory.makeProtocolKeyword (" " , " " );
652+ auto MyCollection = Factory.makeIdentifier (" MyCollection" , " " , " " );
653+ auto ElementName = Factory.makeIdentifier (" Element" , " " , " " );
654+ auto ElementParam =
655+ Factory.makePrimaryAssociatedType (None, ElementName, None, None, None, None);
656+ auto LeftAngle = Factory.makeLeftAngleToken (" " , " " );
657+ auto RightAngle = Factory.makeRightAngleToken (" " , " " );
658+ auto PrimaryAssocs = PrimaryAssociatedTypeClauseSyntaxBuilder (Arena)
659+ .useLeftAngleBracket (LeftAngle)
660+ .useRightAngleBracket (RightAngle)
661+ .addPrimaryAssociatedType (ElementParam)
662+ .build ();
663+
664+ auto LeftBrace = Factory.makeLeftBraceToken (" " , " " );
665+ auto RightBrace = Factory.makeRightBraceToken (" " , " " );
666+ auto Members = MemberDeclBlockSyntaxBuilder (Arena)
667+ .useLeftBrace (LeftBrace)
668+ .useRightBrace (RightBrace)
669+ .build ();
670+ Factory
671+ .makeProtocolDecl (None, None, Protocol, MyCollection, PrimaryAssocs, None, None, Members)
672+ .print (OS);
673+ ASSERT_EQ (OS.str ().str (),
674+ " protocol MyCollection<Element> {}" );
675+ }
676+ }
0 commit comments