Files
carbon-lang/executable_semantics/syntax/unimplemented_example_test.cpp
T
Richard Smith 8c60ad2e19 Implement the current set of rules for precedence partial ordering (#1096)
In the process, switch to an unambiguous grammar, using the
precedence-climbing method for operator precedence (suitably modified to
handle a partial precedence order) rather than Bison %precedence /
%prec.
2022-03-03 13:36:35 -08:00

37 lines
1.3 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include "executable_semantics/ast/ast_test_matchers.h"
#include "executable_semantics/syntax/parse.h"
#include "executable_semantics/syntax/parse_test_matchers.h"
namespace Carbon::Testing {
namespace {
using ::testing::ElementsAre;
TEST(UnimplementedExampleTest, VerifyPrecedence) {
static constexpr std::string_view Program = R"(
package ExecutableSemanticsTest api;
fn Main() -> i32 {
return 1 __unimplemented_example_infix 2 == 3;
}
)";
Arena arena;
EXPECT_THAT(ParseFromString(&arena, "dummy.carbon", Program, false),
ParsedAs(ASTDeclarations(
ElementsAre(MatchesFunctionDeclaration().WithBody(
BlockContentsAre(ElementsAre(MatchesReturn(MatchesEq(
MatchesUnimplementedExpression(
"ExampleInfix", ElementsAre(MatchesLiteral(1),
MatchesLiteral(2))),
MatchesLiteral(3))))))))));
}
} // namespace
} // namespace Carbon::Testing