forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSONTest.cpp
More file actions
42 lines (33 loc) · 1012 Bytes
/
JSONTest.cpp
File metadata and controls
42 lines (33 loc) · 1012 Bytes
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
35
36
37
38
39
40
41
42
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "llvh/Support/Casting.h"
#include "llvh/Support/SourceMgr.h"
#include "hermes/AST/ASTBuilder.h"
#include "hermes/Parser/JSONParser.h"
#include "gtest/gtest.h"
using llvh::cast;
using llvh::dyn_cast;
using namespace hermes;
namespace {
const char *JSONExample =
"{"
" \"type\": \"Program\","
" \"sourceType\": \"script\","
" \"body\": [], "
" \"directives\": []"
"}";
TEST(JSONParserTest, SimpleParserTest) {
Context context;
parser::JSONFactory factory(context.getAllocator());
parser::JSONParser parser(
factory, JSONExample, context.getSourceErrorManager());
auto parsed = parser.parse();
ASSERT_TRUE(parsed.hasValue());
auto Node = hermes::ESTree::buildAST(context, parsed.getValue());
EXPECT_TRUE(Node.hasValue());
}
} // end anonymous namespace