unimplemented_example_test.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include <gmock/gmock.h>
  5. #include <gtest/gtest.h>
  6. #include "executable_semantics/ast/ast_test_matchers.h"
  7. #include "executable_semantics/syntax/parse.h"
  8. #include "executable_semantics/syntax/parse_test_matchers.h"
  9. namespace Carbon::Testing {
  10. namespace {
  11. using ::testing::ElementsAre;
  12. TEST(UnimplementedExampleTest, VerifyPrecedence) {
  13. static constexpr std::string_view Program = R"(
  14. package ExecutableSemanticsTest api;
  15. fn Main() -> i32 {
  16. return 1 __unimplemented_example_infix 2 == 3;
  17. }
  18. )";
  19. Arena arena;
  20. EXPECT_THAT(ParseFromString(&arena, "dummy.carbon", Program, false),
  21. ParsedAs(ASTDeclarations(
  22. ElementsAre(MatchesFunctionDeclaration().WithBody(
  23. BlockContentsAre(ElementsAre(MatchesReturn(MatchesEq(
  24. MatchesUnimplementedExpression(
  25. "ExampleInfix", ElementsAre(MatchesLiteral(1),
  26. MatchesLiteral(2))),
  27. MatchesLiteral(3))))))))));
  28. }
  29. } // namespace
  30. } // namespace Carbon::Testing