forked from carbon-language/carbon-lang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse_test.cpp
34 lines (25 loc) · 810 Bytes
/
parse_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 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 "explorer/syntax/parse.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <string>
#include <variant>
#include "explorer/base/arena.h"
namespace Carbon {
namespace {
static constexpr std::string_view FileContents = R"(
package ExplorerTest api;
fn Foo() {}
)";
TEST(ParseTest, ParseFromString) {
Arena arena;
ErrorOr<AST> parse_result =
ParseFromString(&arena, "file.carbon", FileKind::Main, FileContents,
/*parser_debug=*/false);
ASSERT_TRUE(parse_result.ok());
EXPECT_EQ(parse_result->declarations.size(), 1);
}
} // namespace
} // namespace Carbon