parse_test.cpp 793 B

123456789101112131415161718192021222324252627282930313233
  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/common/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 = ParseFromString(
  19. &arena, "file.carbon", FileContents, /*parser_debug=*/false);
  20. ASSERT_TRUE(parse_result.ok());
  21. EXPECT_EQ(parse_result->declarations.size(), 1);
  22. }
  23. } // namespace
  24. } // namespace Carbon::Testing