Skip to content

Commit f425c39

Browse files
committed
Add FunctionParameterWithEllipsis test case
1 parent 374efd1 commit f425c39

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

unittests/Syntax/DeclSyntaxTests.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,34 @@ TEST(DeclSyntaxTests, FunctionParameterWithAPIs) {
324324
}
325325
}
326326

327+
TEST(DeclSyntaxTests, FunctionParameterWithEllipsis) {
328+
auto ExternalName = SyntaxFactory::makeIdentifier("for", {},
329+
Trivia::spaces(1));
330+
auto LocalName = SyntaxFactory::makeIdentifier("integer", {}, {});
331+
auto Colon = SyntaxFactory::makeColonToken(Trivia::spaces(1),
332+
Trivia::spaces(1));
333+
auto Int = SyntaxFactory::makeTypeIdentifier("Int", {},
334+
Trivia::spaces(0));
335+
auto Ellipsis = SyntaxFactory::makeEllipsisToken({},
336+
Trivia::spaces(1));
337+
auto Comma = SyntaxFactory::makeCommaToken({}, {});
338+
339+
{
340+
SmallString<48> Scratch;
341+
llvm::raw_svector_ostream OS(Scratch);
342+
getCannedFunctionParameter()
343+
.withFirstName(ExternalName)
344+
.withSecondName(LocalName)
345+
.withColon(Colon)
346+
.withType(Int)
347+
.withEllipsis(Ellipsis)
348+
.withDefaultArgument(llvm::None)
349+
.withTrailingComma(Comma)
350+
.print(OS);
351+
ASSERT_EQ(OS.str().str(), "for integer : Int... ,");
352+
}
353+
}
354+
327355
#pragma mark - parameter-list
328356

329357
TEST(DeclSyntaxTests, FunctionParameterListMakeAPIs) {

0 commit comments

Comments
 (0)