mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 22:02:33 +01:00
Support parsing and testing unimplemented expressions (#957)
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
co-authored by
Jon Meow
parent
be0c1e9da6
commit
dc5e62fc7a
@@ -17,6 +17,7 @@ namespace Carbon {
|
||||
namespace {
|
||||
|
||||
using ::testing::_;
|
||||
using ::testing::ElementsAre;
|
||||
using ::testing::IsEmpty;
|
||||
using ::testing::Not;
|
||||
|
||||
@@ -124,5 +125,38 @@ TEST(MatchesFunctionDeclarationTest, BasicUsage) {
|
||||
EXPECT_THAT(body, Not(MatchesFunctionDeclaration()));
|
||||
}
|
||||
|
||||
TEST(MatchesUnimplementedExpressionTest, BasicUsage) {
|
||||
IntLiteral two(DummyLoc, 2);
|
||||
IntLiteral three(DummyLoc, 3);
|
||||
UnimplementedExpression unimplemented(DummyLoc, "DummyLabel", &two, &three);
|
||||
|
||||
EXPECT_THAT(unimplemented, MatchesUnimplementedExpression(
|
||||
"DummyLabel", ElementsAre(MatchesLiteral(2),
|
||||
MatchesLiteral(3))));
|
||||
EXPECT_THAT(
|
||||
&unimplemented,
|
||||
MatchesUnimplementedExpression(
|
||||
"DummyLabel", ElementsAre(MatchesLiteral(2), MatchesLiteral(3))));
|
||||
EXPECT_THAT(
|
||||
unimplemented,
|
||||
Not(MatchesUnimplementedExpression(
|
||||
"WrongLabel", ElementsAre(MatchesLiteral(2), MatchesLiteral(3)))));
|
||||
EXPECT_THAT(unimplemented,
|
||||
Not(MatchesUnimplementedExpression("DummyLabel", IsEmpty())));
|
||||
EXPECT_THAT(two,
|
||||
Not(MatchesUnimplementedExpression("DummyLabel", IsEmpty())));
|
||||
}
|
||||
|
||||
TEST(ASTDeclarationsTest, BasicUsage) {
|
||||
TuplePattern params(DummyLoc, {});
|
||||
Block body(DummyLoc, {});
|
||||
FunctionDeclaration decl(DummyLoc, "Foo", {}, ¶ms,
|
||||
ReturnTerm::Omitted(DummyLoc), &body);
|
||||
AST ast = {.declarations = {&decl}};
|
||||
|
||||
EXPECT_THAT(ast, ASTDeclarations(ElementsAre(MatchesFunctionDeclaration())));
|
||||
EXPECT_THAT(ast, Not(ASTDeclarations(IsEmpty())));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Carbon
|
||||
|
||||
Reference in New Issue
Block a user