Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1795)

Unified Diff: test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc

Issue 2193813002: Add parser finalization step (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher-job.cc ('k') | test/unittests/test-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc
diff --git a/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc b/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc
index 5b8ec478a03d5f4f8a1543f9d1aeac71f8c07ad7..480c3abe68181bbc67f647aa55d62706ee6ca8e0 100644
--- a/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc
+++ b/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc
@@ -49,6 +49,7 @@ Handle<JSFunction> CreateFunction(
isolate->factory()->NewStringFromStaticChars("f"), MaybeHandle<Code>(),
false);
SharedFunctionInfo::SetScript(shared, script);
+ shared->set_end_position(source->length() - 1);
Handle<JSFunction> function =
isolate->factory()->NewFunctionFromSharedFunctionInfo(
shared, handle(isolate->context(), isolate));
@@ -58,36 +59,53 @@ Handle<JSFunction> CreateFunction(
} // namespace
TEST_F(CompilerDispatcherJobTest, Construct) {
- Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate());
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
- i_isolate, CreateFunction(i_isolate, nullptr), FLAG_stack_size));
+ i_isolate(), CreateFunction(i_isolate(), nullptr), FLAG_stack_size));
}
TEST_F(CompilerDispatcherJobTest, CanParseOnBackgroundThread) {
- Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate());
{
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
- i_isolate, CreateFunction(i_isolate, nullptr), FLAG_stack_size));
+ i_isolate(), CreateFunction(i_isolate(), nullptr), FLAG_stack_size));
ASSERT_FALSE(job->can_parse_on_background_thread());
}
{
ScriptResource script("script", strlen("script"));
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
- i_isolate, CreateFunction(i_isolate, &script), FLAG_stack_size));
+ i_isolate(), CreateFunction(i_isolate(), &script), FLAG_stack_size));
ASSERT_TRUE(job->can_parse_on_background_thread());
}
}
TEST_F(CompilerDispatcherJobTest, StateTransitions) {
- Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate());
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
- i_isolate, CreateFunction(i_isolate, nullptr), FLAG_stack_size));
+ i_isolate(), CreateFunction(i_isolate(), nullptr), FLAG_stack_size));
ASSERT_TRUE(job->status() == CompileJobStatus::kInitial);
job->PrepareToParseOnMainThread();
ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToParse);
job->Parse();
ASSERT_TRUE(job->status() == CompileJobStatus::kParsed);
+ job->FinalizeParsingOnMainThread();
+ ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile);
+ job->ResetOnMainThread();
+ ASSERT_TRUE(job->status() == CompileJobStatus::kInitial);
+}
+
+TEST_F(CompilerDispatcherJobTest, SyntaxError) {
+ ScriptResource script("^^^", strlen("^^^"));
+ std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
+ i_isolate(), CreateFunction(i_isolate(), &script), FLAG_stack_size));
+
+ job->PrepareToParseOnMainThread();
+ job->Parse();
+ job->FinalizeParsingOnMainThread();
+
+ ASSERT_TRUE(job->status() == CompileJobStatus::kFailed);
+ ASSERT_FALSE(i_isolate()->has_pending_exception());
+ job->ReportErrorsOnMainThread();
+ ASSERT_TRUE(job->status() == CompileJobStatus::kDone);
+ ASSERT_TRUE(i_isolate()->has_pending_exception());
}
} // namespace internal
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher-job.cc ('k') | test/unittests/test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698