Line data Source code
1 : // Copyright 2016 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_UNITTESTS_TEST_HELPERS_H_
6 : #define V8_UNITTESTS_TEST_HELPERS_H_
7 :
8 : #include <memory>
9 :
10 : #include "include/v8.h"
11 : #include "src/parsing/parse-info.h"
12 :
13 : namespace v8 {
14 :
15 : class Isolate;
16 :
17 : namespace internal {
18 :
19 : class Object;
20 : template <typename T>
21 : class Handle;
22 : class Isolate;
23 :
24 : namespace test {
25 :
26 : class ScriptResource : public v8::String::ExternalOneByteStringResource {
27 : public:
28 : ScriptResource(const char* data, size_t length)
29 25 : : data_(data), length_(length) {}
30 50 : ~ScriptResource() override = default;
31 :
32 71 : const char* data() const override { return data_; }
33 62 : size_t length() const override { return length_; }
34 :
35 : private:
36 : const char* data_;
37 : size_t length_;
38 :
39 : DISALLOW_COPY_AND_ASSIGN(ScriptResource);
40 : };
41 :
42 : Handle<String> CreateSource(
43 : Isolate* isolate,
44 : v8::String::ExternalOneByteStringResource* maybe_resource);
45 : Handle<SharedFunctionInfo> CreateSharedFunctionInfo(
46 : Isolate* isolate,
47 : v8::String::ExternalOneByteStringResource* maybe_resource);
48 : std::unique_ptr<ParseInfo> OuterParseInfoForShared(
49 : Isolate* isolate, Handle<SharedFunctionInfo> shared);
50 :
51 : } // namespace test
52 : } // namespace internal
53 : } // namespace v8
54 :
55 : #endif // V8_UNITTESTS_TEST_HELPERS_H_
|