2016-12-12 15:35:41 +00:00
|
|
|
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2017-04-18 14:01:12 +00:00
|
|
|
#ifndef V8_UNITTESTS_TEST_HELPERS_H_
|
|
|
|
#define V8_UNITTESTS_TEST_HELPERS_H_
|
2016-12-12 15:35:41 +00:00
|
|
|
|
2017-04-06 13:59:07 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include "include/v8.h"
|
|
|
|
#include "src/compiler-dispatcher/compiler-dispatcher-job.h"
|
|
|
|
#include "src/parsing/parse-info.h"
|
|
|
|
|
2016-12-12 15:35:41 +00:00
|
|
|
namespace v8 {
|
|
|
|
|
|
|
|
class Isolate;
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class Object;
|
|
|
|
template <typename T>
|
|
|
|
class Handle;
|
2017-04-06 13:59:07 +00:00
|
|
|
class Isolate;
|
|
|
|
|
|
|
|
namespace test {
|
|
|
|
|
|
|
|
class ScriptResource : public v8::String::ExternalOneByteStringResource {
|
|
|
|
public:
|
|
|
|
ScriptResource(const char* data, size_t length)
|
|
|
|
: data_(data), length_(length) {}
|
|
|
|
~ScriptResource() override = default;
|
|
|
|
|
|
|
|
const char* data() const override { return data_; }
|
|
|
|
size_t length() const override { return length_; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const char* data_;
|
|
|
|
size_t length_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ScriptResource);
|
|
|
|
};
|
|
|
|
|
2017-07-27 13:33:53 +00:00
|
|
|
class FinishCallback : public UnoptimizedCompileJobFinishCallback {
|
2017-04-06 13:59:07 +00:00
|
|
|
public:
|
|
|
|
void ParseFinished(std::unique_ptr<ParseInfo> result) override {
|
|
|
|
result_ = std::move(result);
|
|
|
|
}
|
|
|
|
ParseInfo* result() const { return result_.get(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::unique_ptr<ParseInfo> result_;
|
|
|
|
};
|
2016-12-12 15:35:41 +00:00
|
|
|
|
|
|
|
Handle<Object> RunJS(v8::Isolate* isolate, const char* script);
|
2017-04-06 13:59:07 +00:00
|
|
|
Handle<String> CreateSource(
|
|
|
|
Isolate* isolate,
|
|
|
|
v8::String::ExternalOneByteStringResource* maybe_resource);
|
|
|
|
Handle<SharedFunctionInfo> CreateSharedFunctionInfo(
|
|
|
|
Isolate* isolate,
|
|
|
|
v8::String::ExternalOneByteStringResource* maybe_resource);
|
2016-12-12 15:35:41 +00:00
|
|
|
|
2017-04-06 13:59:07 +00:00
|
|
|
} // namespace test
|
2016-12-12 15:35:41 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
2017-04-18 14:01:12 +00:00
|
|
|
#endif // V8_UNITTESTS_TEST_HELPERS_H_
|