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

Unified Diff: test/cctest/test-api.cc

Issue 186723005: New Compilation API, part 1 (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 years, 9 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 | « test/cctest/cctest.h ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index 01c9ca9b81b23ad7980d451fddf1ecb42b838fb6..f87d7231febcb2f8d8e3f7e18c0547660e8b9f28 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -14952,8 +14952,13 @@ TEST(PreCompileInvalidPreparseDataError) {
sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryEndOffset] = 0;
v8::TryCatch try_catch;
- Local<String> source = String::NewFromUtf8(isolate, script);
- Local<Script> compiled_script = Script::New(source, NULL, sd);
+ v8::ScriptCompiler::Source script_source(
+ String::NewFromUtf8(isolate, script),
+ v8::ScriptCompiler::CachedData(
+ reinterpret_cast<const uint8_t*>(sd->Data()), sd->Length()));
+ Local<v8::UnboundScript> compiled_script =
+ v8::ScriptCompiler::CompileUnbound(isolate, script_source);
+
CHECK(try_catch.HasCaught());
String::Utf8Value exception_value(try_catch.Message()->Get());
CHECK_EQ("Uncaught SyntaxError: Invalid preparser data for function bar",
@@ -14970,7 +14975,12 @@ TEST(PreCompileInvalidPreparseDataError) {
sd_data = reinterpret_cast<unsigned*>(const_cast<char*>(sd->Data()));
sd_data[kHeaderSize + 1 * kFunctionEntrySize + kFunctionEntryStartOffset] =
200;
- compiled_script = Script::New(source, NULL, sd);
+ v8::ScriptCompiler::Source script_source2(
+ String::NewFromUtf8(isolate, script),
+ v8::ScriptCompiler::CachedData(
+ reinterpret_cast<const uint8_t*>(sd->Data()), sd->Length()));
+ compiled_script =
+ v8::ScriptCompiler::CompileUnbound(isolate, script_source2);
CHECK(!try_catch.HasCaught());
delete sd;
@@ -17081,17 +17091,19 @@ THREADED_TEST(ScriptContextDependence) {
const char *source = "foo";
v8::Handle<v8::Script> dep =
v8_compile(source);
- v8::Handle<v8::Script> indep =
- v8::Script::New(v8::String::NewFromUtf8(c1->GetIsolate(), source));
+ v8::Handle<v8::UnboundScript> indep =
+ v8::ScriptCompiler::CompileUnbound(
+ c1->GetIsolate(), v8::ScriptCompiler::Source(v8::String::NewFromUtf8(
+ c1->GetIsolate(), source)));
c1->Global()->Set(v8::String::NewFromUtf8(c1->GetIsolate(), "foo"),
v8::Integer::New(c1->GetIsolate(), 100));
CHECK_EQ(dep->Run()->Int32Value(), 100);
- CHECK_EQ(indep->Run()->Int32Value(), 100);
+ CHECK_EQ(indep->BindToCurrentContext()->Run()->Int32Value(), 100);
LocalContext c2;
c2->Global()->Set(v8::String::NewFromUtf8(c2->GetIsolate(), "foo"),
v8::Integer::New(c2->GetIsolate(), 101));
CHECK_EQ(dep->Run()->Int32Value(), 100);
- CHECK_EQ(indep->Run()->Int32Value(), 101);
+ CHECK_EQ(indep->BindToCurrentContext()->Run()->Int32Value(), 101);
}
@@ -17104,7 +17116,11 @@ THREADED_TEST(StackTrace) {
v8::String::NewFromUtf8(context->GetIsolate(), source);
v8::Handle<v8::String> origin =
v8::String::NewFromUtf8(context->GetIsolate(), "stack-trace-test");
- v8::Script::New(src, origin)->Run();
+ v8::ScriptCompiler::CompileUnbound(
+ context->GetIsolate(),
+ v8::ScriptCompiler::Source(src, v8::ScriptOrigin(origin)))
+ ->BindToCurrentContext()
+ ->Run();
CHECK(try_catch.HasCaught());
v8::String::Utf8Value stack(try_catch.StackTrace());
CHECK(strstr(*stack, "at foo (stack-trace-test") != NULL);
@@ -17211,7 +17227,11 @@ TEST(CaptureStackTrace) {
v8::Handle<v8::String> overview_src =
v8::String::NewFromUtf8(isolate, overview_source);
v8::Handle<Value> overview_result(
- v8::Script::New(overview_src, origin)->Run());
+ v8::ScriptCompiler::CompileUnbound(
+ isolate,
+ v8::ScriptCompiler::Source(overview_src, v8::ScriptOrigin(origin)))
+ ->BindToCurrentContext()
+ ->Run());
CHECK(!overview_result.IsEmpty());
CHECK(overview_result->IsObject());
@@ -17230,9 +17250,11 @@ TEST(CaptureStackTrace) {
v8::Handle<v8::Integer> line_offset = v8::Integer::New(isolate, 3);
v8::Handle<v8::Integer> column_offset = v8::Integer::New(isolate, 5);
v8::ScriptOrigin detailed_origin(origin, line_offset, column_offset);
- v8::Handle<v8::Script> detailed_script(
- v8::Script::New(detailed_src, &detailed_origin));
- v8::Handle<Value> detailed_result(detailed_script->Run());
+ v8::Handle<v8::UnboundScript> detailed_script(
+ v8::ScriptCompiler::CompileUnbound(
+ isolate, v8::ScriptCompiler::Source(detailed_src, detailed_origin)));
+ v8::Handle<Value> detailed_result(
+ detailed_script->BindToCurrentContext()->Run());
CHECK(!detailed_result.IsEmpty());
CHECK(detailed_result->IsObject());
}
« no previous file with comments | « test/cctest/cctest.h ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698