Skip to content

Commit

Permalink
libnixf/test/Parse: add test for parsing op
Browse files Browse the repository at this point in the history
  • Loading branch information
inclyc committed Feb 9, 2024
1 parent 8655b97 commit 38ce0de
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions libnixf/test/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <gtest/gtest.h>

#include "Parser.h"
#include "nixf/Basic/Nodes/Op.h"

namespace {

Expand Down Expand Up @@ -234,4 +235,22 @@ TEST(Parser, ExprDispatch_r_curly_id_ellipsis) {
ASSERT_EQ(AST->kind(), Node::NK_ExprLambda);
}

TEST(Parser, ExprOp) {
auto Src = R"(1 + 2 * 3)"sv;

std::vector<Diagnostic> Diags;
Parser P(Src, Diags);
auto AST = P.parseExpr();

ASSERT_TRUE(AST);
ASSERT_EQ(AST->kind(), Node::NK_ExprBinOp);

auto &BinOp = *static_cast<ExprBinOp *>(AST.get());

ASSERT_TRUE(BinOp.lhs());
ASSERT_TRUE(BinOp.rhs());
ASSERT_EQ(BinOp.rhs()->kind(), Node::NK_ExprBinOp);
ASSERT_EQ(BinOp.lhs()->kind(), Node::NK_ExprInt);
}

} // namespace

0 comments on commit 38ce0de

Please sign in to comment.