mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
This will be more correct if a user file is named prelude.carbon, and reduces the explorer runtime by about 10% by removing a string comparison from the check for whether trace output is enabled. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
38 lines
1.2 KiB
C++
38 lines
1.2 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 "explorer/ast/ast_test_matchers.h"
|
|
#include "explorer/syntax/parse.h"
|
|
#include "explorer/syntax/parse_test_matchers.h"
|
|
|
|
namespace Carbon::Testing {
|
|
namespace {
|
|
|
|
using ::testing::ElementsAre;
|
|
|
|
TEST(UnimplementedExampleTest, VerifyPrecedence) {
|
|
static constexpr std::string_view Program = R"(
|
|
package ExplorerTest api;
|
|
fn Main() -> i32 {
|
|
return 1 __unimplemented_example_infix 2 == 3;
|
|
}
|
|
)";
|
|
Arena arena;
|
|
EXPECT_THAT(
|
|
ParseFromString(&arena, "dummy.carbon", FileKind::Main, Program, false),
|
|
ParsedAs(
|
|
ASTDeclarations(ElementsAre(MatchesFunctionDeclaration().WithBody(
|
|
BlockContentsAre(ElementsAre(MatchesReturn(MatchesEq(
|
|
MatchesUnimplementedExpression(
|
|
"ExampleInfix",
|
|
ElementsAre(MatchesLiteral(1), MatchesLiteral(2))),
|
|
MatchesLiteral(3))))))))));
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace Carbon::Testing
|