unimplemented_example_test.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 "explorer/ast/ast_test_matchers.h"
  7. #include "explorer/syntax/parse.h"
  8. #include "explorer/syntax/parse_test_matchers.h"
  9. namespace Carbon {
  10. namespace {
  11. using ::testing::ElementsAre;
  12. TEST(UnimplementedExampleTest, VerifyPrecedence) {
  13. static constexpr std::string_view Program = R"(
  14. package ExplorerTest api;
  15. fn Main() -> i32 {
  16. return 1 __unimplemented_example_infix 2 == 3;
  17. }
  18. )";
  19. Arena arena;
  20. EXPECT_THAT(
  21. ParseFromString(&arena, "dummy.carbon", FileKind::Main, Program, false),
  22. ParsedAs(
  23. ASTDeclarations(ElementsAre(MatchesFunctionDeclaration().WithBody(
  24. BlockContentsAre(ElementsAre(MatchesReturn(MatchesEq(
  25. MatchesUnimplementedExpression(
  26. "ExampleInfix",
  27. ElementsAre(MatchesLiteral(1), MatchesLiteral(2))),
  28. MatchesLiteral(3))))))))));
  29. }
  30. } // namespace
  31. } // namespace Carbon