parse_test.cpp 828 B

12345678910111213141516171819202122232425262728293031323334
  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 "explorer/syntax/parse.h"
  5. #include <gmock/gmock.h>
  6. #include <gtest/gtest.h>
  7. #include <string>
  8. #include <variant>
  9. #include "explorer/base/arena.h"
  10. namespace Carbon::Testing {
  11. namespace {
  12. static constexpr std::string_view FileContents = R"(
  13. package ExplorerTest api;
  14. fn Foo() {}
  15. )";
  16. TEST(ParseTest, ParseFromString) {
  17. Arena arena;
  18. ErrorOr<AST> parse_result =
  19. ParseFromString(&arena, "file.carbon", FileKind::Main, FileContents,
  20. /*parser_debug=*/false);
  21. ASSERT_TRUE(parse_result.ok());
  22. EXPECT_EQ(parse_result->declarations.size(), 1);
  23. }
  24. } // namespace
  25. } // namespace Carbon::Testing