Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 35f2d91f6955016872799caecc508919a09b276f..fbb6e56e9270e2651dad911d2f10f91b47cb042a 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -204,9 +204,8 @@ THREADED_TEST(Handles) { |
CHECK(!undef.IsEmpty()); |
CHECK(undef->IsUndefined()); |
- const char* c_source = "1 + 2 + 3"; |
- Local<String> source = String::NewFromUtf8(CcTest::isolate(), c_source); |
- Local<Script> script = Script::Compile(source); |
+ const char* source = "1 + 2 + 3"; |
+ Local<Script> script = v8_compile(source); |
CHECK_EQ(6, script->Run()->Int32Value()); |
local_env->Exit(); |
@@ -445,9 +444,8 @@ THREADED_TEST(AccessElement) { |
THREADED_TEST(Script) { |
LocalContext env; |
v8::HandleScope scope(env->GetIsolate()); |
- const char* c_source = "1 + 2 + 3"; |
- Local<String> source = String::NewFromUtf8(env->GetIsolate(), c_source); |
- Local<Script> script = Script::Compile(source); |
+ const char* source = "1 + 2 + 3"; |
+ Local<Script> script = v8_compile(source); |
CHECK_EQ(6, script->Run()->Int32Value()); |
} |
@@ -526,7 +524,7 @@ THREADED_TEST(ScriptUsingStringResource) { |
v8::HandleScope scope(env->GetIsolate()); |
TestResource* resource = new TestResource(two_byte_source, &dispose_count); |
Local<String> source = String::NewExternal(env->GetIsolate(), resource); |
- Local<Script> script = Script::Compile(source); |
+ Local<Script> script = v8_compile(source); |
Local<Value> value = script->Run(); |
CHECK(value->IsNumber()); |
CHECK_EQ(7, value->Int32Value()); |
@@ -562,7 +560,7 @@ THREADED_TEST(ScriptUsingAsciiStringResource) { |
CHECK_EQ(static_cast<const String::ExternalStringResourceBase*>(resource), |
source->GetExternalStringResourceBase(&encoding)); |
CHECK_EQ(String::ASCII_ENCODING, encoding); |
- Local<Script> script = Script::Compile(source); |
+ Local<Script> script = v8_compile(source); |
Local<Value> value = script->Run(); |
CHECK(value->IsNumber()); |
CHECK_EQ(7, value->Int32Value()); |
@@ -594,7 +592,7 @@ THREADED_TEST(ScriptMakingExternalString) { |
bool success = source->MakeExternal(new TestResource(two_byte_source, |
&dispose_count)); |
CHECK(success); |
- Local<Script> script = Script::Compile(source); |
+ Local<Script> script = v8_compile(source); |
Local<Value> value = script->Run(); |
CHECK(value->IsNumber()); |
CHECK_EQ(7, value->Int32Value()); |
@@ -620,7 +618,7 @@ THREADED_TEST(ScriptMakingExternalAsciiString) { |
bool success = source->MakeExternal( |
new TestAsciiResource(i::StrDup(c_source), &dispose_count)); |
CHECK(success); |
- Local<Script> script = Script::Compile(source); |
+ Local<Script> script = v8_compile(source); |
Local<Value> value = script->Run(); |
CHECK(value->IsNumber()); |
CHECK_EQ(7, value->Int32Value()); |
@@ -871,7 +869,7 @@ TEST(ExternalStringWithDisposeHandling) { |
LocalContext env; |
v8::HandleScope scope(env->GetIsolate()); |
Local<String> source = String::NewExternal(env->GetIsolate(), &res_stack); |
- Local<Script> script = Script::Compile(source); |
+ Local<Script> script = v8_compile(source); |
Local<Value> value = script->Run(); |
CHECK(value->IsNumber()); |
CHECK_EQ(7, value->Int32Value()); |
@@ -892,7 +890,7 @@ TEST(ExternalStringWithDisposeHandling) { |
LocalContext env; |
v8::HandleScope scope(env->GetIsolate()); |
Local<String> source = String::NewExternal(env->GetIsolate(), res_heap); |
- Local<Script> script = Script::Compile(source); |
+ Local<Script> script = v8_compile(source); |
Local<Value> value = script->Run(); |
CHECK(value->IsNumber()); |
CHECK_EQ(7, value->Int32Value()); |
@@ -944,7 +942,7 @@ THREADED_TEST(StringConcat) { |
env->GetIsolate(), |
new TestResource(AsciiToTwoByteString(two_byte_extern_2))); |
source = String::Concat(source, right); |
- Local<Script> script = Script::Compile(source); |
+ Local<Script> script = v8_compile(source); |
Local<Value> value = script->Run(); |
CHECK(value->IsNumber()); |
CHECK_EQ(68, value->Int32Value()); |
@@ -2397,23 +2395,23 @@ THREADED_PROFILED_TEST(PropertyHandlerInPrototype) { |
env->Global()->Set(v8_str("obj"), bottom); |
// Indexed and named get. |
- Script::Compile(v8_str("obj[0]"))->Run(); |
- Script::Compile(v8_str("obj.x"))->Run(); |
+ CompileRun("obj[0]"); |
+ CompileRun("obj.x"); |
// Indexed and named set. |
- Script::Compile(v8_str("obj[1] = 42"))->Run(); |
- Script::Compile(v8_str("obj.y = 42"))->Run(); |
+ CompileRun("obj[1] = 42"); |
+ CompileRun("obj.y = 42"); |
// Indexed and named query. |
- Script::Compile(v8_str("0 in obj"))->Run(); |
- Script::Compile(v8_str("'x' in obj"))->Run(); |
+ CompileRun("0 in obj"); |
+ CompileRun("'x' in obj"); |
// Indexed and named deleter. |
- Script::Compile(v8_str("delete obj[0]"))->Run(); |
- Script::Compile(v8_str("delete obj.x"))->Run(); |
+ CompileRun("delete obj[0]"); |
+ CompileRun("delete obj.x"); |
// Enumerators. |
- Script::Compile(v8_str("for (var p in obj) ;"))->Run(); |
+ CompileRun("for (var p in obj) ;"); |
} |
@@ -2444,13 +2442,12 @@ THREADED_TEST(PrePropertyHandler) { |
0, |
PrePropertyHandlerQuery); |
LocalContext env(NULL, desc->InstanceTemplate()); |
- Script::Compile(v8_str( |
- "var pre = 'Object: pre'; var on = 'Object: on';"))->Run(); |
- v8::Handle<Value> result_pre = Script::Compile(v8_str("pre"))->Run(); |
+ CompileRun("var pre = 'Object: pre'; var on = 'Object: on';"); |
+ v8::Handle<Value> result_pre = CompileRun("pre"); |
CHECK_EQ(v8_str("PrePropertyHandler: pre"), result_pre); |
- v8::Handle<Value> result_on = Script::Compile(v8_str("on"))->Run(); |
+ v8::Handle<Value> result_on = CompileRun("on"); |
CHECK_EQ(v8_str("Object: on"), result_on); |
- v8::Handle<Value> result_post = Script::Compile(v8_str("post"))->Run(); |
+ v8::Handle<Value> result_post = CompileRun("post"); |
CHECK(result_post.IsEmpty()); |
} |
@@ -2458,8 +2455,7 @@ THREADED_TEST(PrePropertyHandler) { |
THREADED_TEST(UndefinedIsNotEnumerable) { |
LocalContext env; |
v8::HandleScope scope(env->GetIsolate()); |
- v8::Handle<Value> result = Script::Compile(v8_str( |
- "this.propertyIsEnumerable(undefined)"))->Run(); |
+ v8::Handle<Value> result = CompileRun("this.propertyIsEnumerable(undefined)"); |
CHECK(result->IsFalse()); |
} |
@@ -2512,7 +2508,7 @@ THREADED_TEST(DeepCrossLanguageRecursion) { |
call_recursively_script = v8::Handle<Script>(); |
env->Global()->Set(v8_str("depth"), v8::Integer::New(isolate, 0)); |
- Script::Compile(v8_str("callFunctionRecursively()"))->Run(); |
+ CompileRun("callFunctionRecursively()"); |
} |
@@ -2541,11 +2537,11 @@ THREADED_TEST(CallbackExceptionRegression) { |
ThrowingPropertyHandlerSet); |
LocalContext env; |
env->Global()->Set(v8_str("obj"), obj->NewInstance()); |
- v8::Handle<Value> otto = Script::Compile(v8_str( |
- "try { with (obj) { otto; } } catch (e) { e; }"))->Run(); |
+ v8::Handle<Value> otto = CompileRun( |
+ "try { with (obj) { otto; } } catch (e) { e; }"); |
CHECK_EQ(v8_str("otto"), otto); |
- v8::Handle<Value> netto = Script::Compile(v8_str( |
- "try { with (obj) { netto = 4; } } catch (e) { e; }"))->Run(); |
+ v8::Handle<Value> netto = CompileRun( |
+ "try { with (obj) { netto = 4; } } catch (e) { e; }"); |
CHECK_EQ(v8_str("netto"), netto); |
} |
@@ -2557,7 +2553,7 @@ THREADED_TEST(FunctionPrototype) { |
Foo->PrototypeTemplate()->Set(v8_str("plak"), v8_num(321)); |
LocalContext env; |
env->Global()->Set(v8_str("Foo"), Foo->GetFunction()); |
- Local<Script> script = Script::Compile(v8_str("Foo.prototype.plak")); |
+ Local<Script> script = v8_compile("Foo.prototype.plak"); |
CHECK_EQ(script->Run()->Int32Value(), 321); |
} |
@@ -3279,7 +3275,7 @@ THREADED_TEST(External) { |
Local<v8::External> ext = v8::External::New(CcTest::isolate(), &x); |
LocalContext env; |
env->Global()->Set(v8_str("ext"), ext); |
- Local<Value> reext_obj = Script::Compile(v8_str("this.ext"))->Run(); |
+ Local<Value> reext_obj = CompileRun("this.ext"); |
v8::Handle<v8::External> reext = reext_obj.As<v8::External>(); |
int* ptr = static_cast<int*>(reext->Value()); |
CHECK_EQ(x, 3); |
@@ -3950,7 +3946,7 @@ TEST(ApiObjectGroupsCycleForScavenger) { |
THREADED_TEST(ScriptException) { |
LocalContext env; |
v8::HandleScope scope(env->GetIsolate()); |
- Local<Script> script = Script::Compile(v8_str("throw 'panama!';")); |
+ Local<Script> script = v8_compile("throw 'panama!';"); |
v8::TryCatch try_catch; |
Local<Value> result = script->Run(); |
CHECK(result.IsEmpty()); |
@@ -3990,10 +3986,7 @@ THREADED_TEST(MessageHandler0) { |
CHECK(!message_received); |
LocalContext context; |
v8::V8::AddMessageListener(check_message_0, v8_num(5.76)); |
- v8::ScriptOrigin origin = |
- v8::ScriptOrigin(v8_str("6.75")); |
- v8::Handle<v8::Script> script = Script::Compile(v8_str("throw 'error'"), |
- &origin); |
+ v8::Handle<v8::Script> script = CompileWithOrigin("throw 'error'", "6.75"); |
script->Run(); |
CHECK(message_received); |
// clear out the message listener |
@@ -4169,13 +4162,13 @@ THREADED_TEST(GetSetProperty) { |
context->Global()->Set(v8_str("12"), v8_num(92)); |
context->Global()->Set(v8::Integer::New(isolate, 16), v8_num(32)); |
context->Global()->Set(v8_num(13), v8_num(56)); |
- Local<Value> foo = Script::Compile(v8_str("this.foo"))->Run(); |
+ Local<Value> foo = CompileRun("this.foo"); |
CHECK_EQ(14, foo->Int32Value()); |
- Local<Value> twelve = Script::Compile(v8_str("this[12]"))->Run(); |
+ Local<Value> twelve = CompileRun("this[12]"); |
CHECK_EQ(92, twelve->Int32Value()); |
- Local<Value> sixteen = Script::Compile(v8_str("this[16]"))->Run(); |
+ Local<Value> sixteen = CompileRun("this[16]"); |
CHECK_EQ(32, sixteen->Int32Value()); |
- Local<Value> thirteen = Script::Compile(v8_str("this[13]"))->Run(); |
+ Local<Value> thirteen = CompileRun("this[13]"); |
CHECK_EQ(56, thirteen->Int32Value()); |
CHECK_EQ(92, |
context->Global()->Get(v8::Integer::New(isolate, 12))->Int32Value()); |
@@ -4204,7 +4197,7 @@ THREADED_TEST(PropertyAttributes) { |
context->Global()->Set(prop, v8_num(7), v8::ReadOnly); |
CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); |
CHECK_EQ(v8::ReadOnly, context->Global()->GetPropertyAttributes(prop)); |
- Script::Compile(v8_str("read_only = 9"))->Run(); |
+ CompileRun("read_only = 9"); |
CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); |
context->Global()->Set(prop, v8_num(10)); |
CHECK_EQ(7, context->Global()->Get(prop)->Int32Value()); |
@@ -4212,7 +4205,7 @@ THREADED_TEST(PropertyAttributes) { |
prop = v8_str("dont_delete"); |
context->Global()->Set(prop, v8_num(13), v8::DontDelete); |
CHECK_EQ(13, context->Global()->Get(prop)->Int32Value()); |
- Script::Compile(v8_str("delete dont_delete"))->Run(); |
+ CompileRun("delete dont_delete"); |
CHECK_EQ(13, context->Global()->Get(prop)->Int32Value()); |
CHECK_EQ(v8::DontDelete, context->Global()->GetPropertyAttributes(prop)); |
// dont-enum |
@@ -4251,7 +4244,7 @@ THREADED_TEST(Array) { |
CHECK(!array->Has(1)); |
CHECK(array->Has(2)); |
CHECK_EQ(7, array->Get(2)->Int32Value()); |
- Local<Value> obj = Script::Compile(v8_str("[1, 2, 3]"))->Run(); |
+ Local<Value> obj = CompileRun("[1, 2, 3]"); |
Local<v8::Array> arr = obj.As<v8::Array>(); |
CHECK_EQ(3, arr->Length()); |
CHECK_EQ(1, arr->Get(0)->Int32Value()); |
@@ -4422,9 +4415,7 @@ TEST(OutOfMemory) { |
LocalContext context; |
v8::HandleScope scope(context->GetIsolate()); |
v8::V8::IgnoreOutOfMemoryException(); |
- Local<Script> script = Script::Compile(String::NewFromUtf8( |
- context->GetIsolate(), js_code_causing_out_of_memory)); |
- Local<Value> result = script->Run(); |
+ Local<Value> result = CompileRun(js_code_causing_out_of_memory); |
// Check for out of memory state. |
CHECK(result.IsEmpty()); |
@@ -4437,9 +4428,7 @@ void ProvokeOutOfMemory(const v8::FunctionCallbackInfo<v8::Value>& args) { |
LocalContext context; |
v8::HandleScope scope(context->GetIsolate()); |
- Local<Script> script = Script::Compile(String::NewFromUtf8( |
- context->GetIsolate(), js_code_causing_out_of_memory)); |
- Local<Value> result = script->Run(); |
+ Local<Value> result = CompileRun(js_code_causing_out_of_memory); |
// Check for out of memory state. |
CHECK(result.IsEmpty()); |
@@ -4737,7 +4726,7 @@ void CCatcher(const v8::FunctionCallbackInfo<v8::Value>& args) { |
} |
v8::HandleScope scope(args.GetIsolate()); |
v8::TryCatch try_catch; |
- Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); |
+ Local<Value> result = CompileRun(args[0]->ToString()); |
CHECK(!try_catch.HasCaught() || result.IsEmpty()); |
args.GetReturnValue().Set(try_catch.HasCaught()); |
} |
@@ -4999,9 +4988,7 @@ THREADED_TEST(ExternalScriptException) { |
LocalContext context(0, templ); |
v8::TryCatch try_catch; |
- Local<Script> script |
- = Script::Compile(v8_str("ThrowFromC(); throw 'panama';")); |
- Local<Value> result = script->Run(); |
+ Local<Value> result = CompileRun("ThrowFromC(); throw 'panama';"); |
CHECK(result.IsEmpty()); |
CHECK(try_catch.HasCaught()); |
String::Utf8Value exception_value(try_catch.Exception()); |
@@ -5193,12 +5180,12 @@ THREADED_TEST(CatchZero) { |
v8::HandleScope scope(context->GetIsolate()); |
v8::TryCatch try_catch; |
CHECK(!try_catch.HasCaught()); |
- Script::Compile(v8_str("throw 10"))->Run(); |
+ CompileRun("throw 10"); |
CHECK(try_catch.HasCaught()); |
CHECK_EQ(10, try_catch.Exception()->Int32Value()); |
try_catch.Reset(); |
CHECK(!try_catch.HasCaught()); |
- Script::Compile(v8_str("throw 0"))->Run(); |
+ CompileRun("throw 0"); |
CHECK(try_catch.HasCaught()); |
CHECK_EQ(0, try_catch.Exception()->Int32Value()); |
} |
@@ -5209,7 +5196,7 @@ THREADED_TEST(CatchExceptionFromWith) { |
v8::HandleScope scope(context->GetIsolate()); |
v8::TryCatch try_catch; |
CHECK(!try_catch.HasCaught()); |
- Script::Compile(v8_str("var o = {}; with (o) { throw 42; }"))->Run(); |
+ CompileRun("var o = {}; with (o) { throw 42; }"); |
CHECK(try_catch.HasCaught()); |
} |
@@ -5361,7 +5348,7 @@ THREADED_TEST(Equality) { |
THREADED_TEST(MultiRun) { |
LocalContext context; |
v8::HandleScope scope(context->GetIsolate()); |
- Local<Script> script = Script::Compile(v8_str("x")); |
+ Local<Script> script = v8_compile("x"); |
for (int i = 0; i < 10; i++) |
script->Run(); |
} |
@@ -5383,7 +5370,7 @@ THREADED_TEST(SimplePropertyRead) { |
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
templ->SetAccessor(v8_str("x"), GetXValue, NULL, v8_str("donut")); |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
- Local<Script> script = Script::Compile(v8_str("obj.x")); |
+ Local<Script> script = v8_compile("obj.x"); |
for (int i = 0; i < 10; i++) { |
Local<Value> result = script->Run(); |
CHECK_EQ(result, v8_str("x")); |
@@ -5400,19 +5387,19 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) { |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
// Uses getOwnPropertyDescriptor to check the configurable status |
- Local<Script> script_desc |
- = Script::Compile(v8_str("var prop = Object.getOwnPropertyDescriptor( " |
- "obj, 'x');" |
- "prop.configurable;")); |
+ Local<Script> script_desc = v8_compile( |
+ "var prop = Object.getOwnPropertyDescriptor( " |
+ "obj, 'x');" |
+ "prop.configurable;"); |
Local<Value> result = script_desc->Run(); |
CHECK_EQ(result->BooleanValue(), true); |
// Redefine get - but still configurable |
- Local<Script> script_define |
- = Script::Compile(v8_str("var desc = { get: function(){return 42; }," |
- " configurable: true };" |
- "Object.defineProperty(obj, 'x', desc);" |
- "obj.x")); |
+ Local<Script> script_define = v8_compile( |
+ "var desc = { get: function(){return 42; }," |
+ " configurable: true };" |
+ "Object.defineProperty(obj, 'x', desc);" |
+ "obj.x"); |
result = script_define->Run(); |
CHECK_EQ(result, v8_num(42)); |
@@ -5421,11 +5408,11 @@ THREADED_TEST(DefinePropertyOnAPIAccessor) { |
CHECK_EQ(result->BooleanValue(), true); |
// Redefine to a non-configurable |
- script_define |
- = Script::Compile(v8_str("var desc = { get: function(){return 43; }," |
- " configurable: false };" |
- "Object.defineProperty(obj, 'x', desc);" |
- "obj.x")); |
+ script_define = v8_compile( |
+ "var desc = { get: function(){return 43; }," |
+ " configurable: false };" |
+ "Object.defineProperty(obj, 'x', desc);" |
+ "obj.x"); |
result = script_define->Run(); |
CHECK_EQ(result, v8_num(43)); |
result = script_desc->Run(); |
@@ -5448,18 +5435,19 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) { |
LocalContext context; |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
- Local<Script> script_desc = Script::Compile(v8_str("var prop =" |
- "Object.getOwnPropertyDescriptor( " |
- "obj, 'x');" |
- "prop.configurable;")); |
+ Local<Script> script_desc = v8_compile( |
+ "var prop =" |
+ "Object.getOwnPropertyDescriptor( " |
+ "obj, 'x');" |
+ "prop.configurable;"); |
Local<Value> result = script_desc->Run(); |
CHECK_EQ(result->BooleanValue(), true); |
- Local<Script> script_define = |
- Script::Compile(v8_str("var desc = {get: function(){return 42; }," |
- " configurable: true };" |
- "Object.defineProperty(obj, 'x', desc);" |
- "obj.x")); |
+ Local<Script> script_define = v8_compile( |
+ "var desc = {get: function(){return 42; }," |
+ " configurable: true };" |
+ "Object.defineProperty(obj, 'x', desc);" |
+ "obj.x"); |
result = script_define->Run(); |
CHECK_EQ(result, v8_num(42)); |
@@ -5468,11 +5456,11 @@ THREADED_TEST(DefinePropertyOnDefineGetterSetter) { |
CHECK_EQ(result->BooleanValue(), true); |
- script_define = |
- Script::Compile(v8_str("var desc = {get: function(){return 43; }," |
- " configurable: false };" |
- "Object.defineProperty(obj, 'x', desc);" |
- "obj.x")); |
+ script_define = v8_compile( |
+ "var desc = {get: function(){return 43; }," |
+ " configurable: false };" |
+ "Object.defineProperty(obj, 'x', desc);" |
+ "obj.x"); |
result = script_define->Run(); |
CHECK_EQ(result, v8_num(43)); |
result = script_desc->Run(); |
@@ -5671,7 +5659,7 @@ THREADED_TEST(SimplePropertyWrite) { |
templ->SetAccessor(v8_str("x"), GetXValue, SetXValue, v8_str("donut")); |
LocalContext context; |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
- Local<Script> script = Script::Compile(v8_str("obj.x = 4")); |
+ Local<Script> script = v8_compile("obj.x = 4"); |
for (int i = 0; i < 10; i++) { |
CHECK(xValue.IsEmpty()); |
script->Run(); |
@@ -5688,7 +5676,7 @@ THREADED_TEST(SetterOnly) { |
templ->SetAccessor(v8_str("x"), NULL, SetXValue, v8_str("donut")); |
LocalContext context; |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
- Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |
+ Local<Script> script = v8_compile("obj.x = 4; obj.x"); |
for (int i = 0; i < 10; i++) { |
CHECK(xValue.IsEmpty()); |
script->Run(); |
@@ -5708,7 +5696,7 @@ THREADED_TEST(NoAccessors) { |
v8_str("donut")); |
LocalContext context; |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
- Local<Script> script = Script::Compile(v8_str("obj.x = 4; obj.x")); |
+ Local<Script> script = v8_compile("obj.x = 4; obj.x"); |
for (int i = 0; i < 10; i++) { |
script->Run(); |
} |
@@ -5730,7 +5718,7 @@ THREADED_TEST(NamedInterceptorPropertyRead) { |
templ->SetNamedPropertyHandler(XPropertyGetter); |
LocalContext context; |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
- Local<Script> script = Script::Compile(v8_str("obj.x")); |
+ Local<Script> script = v8_compile("obj.x"); |
for (int i = 0; i < 10; i++) { |
Local<Value> result = script->Run(); |
CHECK_EQ(result, v8_str("x")); |
@@ -5746,7 +5734,7 @@ THREADED_TEST(NamedInterceptorDictionaryIC) { |
LocalContext context; |
// Create an object with a named interceptor. |
context->Global()->Set(v8_str("interceptor_obj"), templ->NewInstance()); |
- Local<Script> script = Script::Compile(v8_str("interceptor_obj.x")); |
+ Local<Script> script = v8_compile("interceptor_obj.x"); |
for (int i = 0; i < 10; i++) { |
Local<Value> result = script->Run(); |
CHECK_EQ(result, v8_str("x")); |
@@ -5869,18 +5857,18 @@ THREADED_TEST(IndexedInterceptorWithIndexedAccessor) { |
IndexedPropertySetter); |
LocalContext context; |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
- Local<Script> getter_script = Script::Compile(v8_str( |
- "obj.__defineGetter__(\"3\", function(){return 5;});obj[3];")); |
- Local<Script> setter_script = Script::Compile(v8_str( |
+ Local<Script> getter_script = v8_compile( |
+ "obj.__defineGetter__(\"3\", function(){return 5;});obj[3];"); |
+ Local<Script> setter_script = v8_compile( |
"obj.__defineSetter__(\"17\", function(val){this.foo = val;});" |
"obj[17] = 23;" |
- "obj.foo;")); |
- Local<Script> interceptor_setter_script = Script::Compile(v8_str( |
+ "obj.foo;"); |
+ Local<Script> interceptor_setter_script = v8_compile( |
"obj.__defineSetter__(\"39\", function(val){this.foo = \"hit\";});" |
"obj[39] = 47;" |
- "obj.foo;")); // This setter should not run, due to the interceptor. |
- Local<Script> interceptor_getter_script = Script::Compile(v8_str( |
- "obj[37];")); |
+ "obj.foo;"); // This setter should not run, due to the interceptor. |
+ Local<Script> interceptor_getter_script = v8_compile( |
+ "obj[37];"); |
Local<Value> result = getter_script->Run(); |
CHECK_EQ(v8_num(5), result); |
result = setter_script->Run(); |
@@ -5916,10 +5904,10 @@ static void UnboxedDoubleIndexedPropertySetter( |
void UnboxedDoubleIndexedPropertyEnumerator( |
const v8::PropertyCallbackInfo<v8::Array>& info) { |
// Force the list of returned keys to be stored in a FastDoubleArray. |
- Local<Script> indexed_property_names_script = Script::Compile(v8_str( |
+ Local<Script> indexed_property_names_script = v8_compile( |
"keys = new Array(); keys[125000] = 1;" |
"for(i = 0; i < 80000; i++) { keys[i] = i; };" |
- "keys.length = 25; keys;")); |
+ "keys.length = 25; keys;"); |
Local<Value> result = indexed_property_names_script->Run(); |
info.GetReturnValue().Set(Local<v8::Array>::Cast(result)); |
} |
@@ -5939,15 +5927,14 @@ THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { |
LocalContext context; |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
// When obj is created, force it to be Stored in a FastDoubleArray. |
- Local<Script> create_unboxed_double_script = Script::Compile(v8_str( |
+ Local<Script> create_unboxed_double_script = v8_compile( |
"obj[125000] = 1; for(i = 0; i < 80000; i+=2) { obj[i] = i; } " |
"key_count = 0; " |
"for (x in obj) {key_count++;};" |
- "obj;")); |
+ "obj;"); |
Local<Value> result = create_unboxed_double_script->Run(); |
CHECK(result->ToObject()->HasRealIndexedProperty(2000)); |
- Local<Script> key_count_check = Script::Compile(v8_str( |
- "key_count;")); |
+ Local<Script> key_count_check = v8_compile("key_count;"); |
result = key_count_check->Run(); |
CHECK_EQ(v8_num(40013), result); |
} |
@@ -5956,12 +5943,12 @@ THREADED_TEST(IndexedInterceptorUnboxedDoubleWithIndexedAccessor) { |
void NonStrictArgsIndexedPropertyEnumerator( |
const v8::PropertyCallbackInfo<v8::Array>& info) { |
// Force the list of returned keys to be stored in a Arguments object. |
- Local<Script> indexed_property_names_script = Script::Compile(v8_str( |
+ Local<Script> indexed_property_names_script = v8_compile( |
"function f(w,x) {" |
" return arguments;" |
"}" |
"keys = f(0, 1, 2, 3);" |
- "keys;")); |
+ "keys;"); |
Local<Object> result = |
Local<Object>::Cast(indexed_property_names_script->Run()); |
// Have to populate the handle manually, as it's not Cast-able. |
@@ -5995,10 +5982,9 @@ THREADED_TEST(IndexedInterceptorNonStrictArgsWithIndexedAccessor) { |
NonStrictArgsIndexedPropertyEnumerator); |
LocalContext context; |
context->Global()->Set(v8_str("obj"), templ->NewInstance()); |
- Local<Script> create_args_script = |
- Script::Compile(v8_str( |
- "var key_count = 0;" |
- "for (x in obj) {key_count++;} key_count;")); |
+ Local<Script> create_args_script = v8_compile( |
+ "var key_count = 0;" |
+ "for (x in obj) {key_count++;} key_count;"); |
Local<Value> result = create_args_script->Run(); |
CHECK_EQ(v8_num(4), result); |
} |
@@ -6373,11 +6359,11 @@ THREADED_TEST(Regress892105) { |
"8901"); |
LocalContext env0; |
- Local<Script> script0 = Script::Compile(source); |
+ Local<Script> script0 = v8_compile(source); |
CHECK_EQ(8901.0, script0->Run()->NumberValue()); |
LocalContext env1; |
- Local<Script> script1 = Script::Compile(source); |
+ Local<Script> script1 = v8_compile(source); |
CHECK_EQ(8901.0, script1->Run()->NumberValue()); |
} |
@@ -6484,19 +6470,19 @@ THREADED_TEST(ExtensibleOnUndetectable) { |
Local<String> source = v8_str("undetectable.x = 42;" |
"undetectable.x"); |
- Local<Script> script = Script::Compile(source); |
+ Local<Script> script = v8_compile(source); |
CHECK_EQ(v8::Integer::New(isolate, 42), script->Run()); |
ExpectBoolean("Object.isExtensible(undetectable)", true); |
source = v8_str("Object.preventExtensions(undetectable);"); |
- script = Script::Compile(source); |
+ script = v8_compile(source); |
script->Run(); |
ExpectBoolean("Object.isExtensible(undetectable)", false); |
source = v8_str("undetectable.y = 2000;"); |
- script = Script::Compile(source); |
+ script = v8_compile(source); |
script->Run(); |
ExpectBoolean("undetectable.y == undefined", true); |
} |
@@ -6589,7 +6575,7 @@ TEST(PersistentHandles) { |
Local<String> str = v8_str("foo"); |
v8::Persistent<String> p_str(isolate, str); |
p_str.Reset(); |
- Local<Script> scr = Script::Compile(v8_str("")); |
+ Local<Script> scr = v8_compile(""); |
v8::Persistent<Script> p_scr(isolate, scr); |
p_scr.Reset(); |
Local<ObjectTemplate> templ = ObjectTemplate::New(isolate); |
@@ -6612,7 +6598,7 @@ THREADED_TEST(GlobalObjectTemplate) { |
v8::FunctionTemplate::New(isolate, HandleLogDelegator)); |
v8::Local<Context> context = Context::New(isolate, 0, global_template); |
Context::Scope context_scope(context); |
- Script::Compile(v8_str("JSNI_Log('LOG')"))->Run(); |
+ CompileRun("JSNI_Log('LOG')"); |
} |
@@ -6630,7 +6616,7 @@ TEST(SimpleExtensions) { |
v8::Handle<Context> context = |
Context::New(CcTest::isolate(), &extensions); |
Context::Scope lock(context); |
- v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
+ v8::Handle<Value> result = CompileRun("Foo()"); |
CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
} |
@@ -6643,7 +6629,7 @@ TEST(NullExtensions) { |
v8::Handle<Context> context = |
Context::New(CcTest::isolate(), &extensions); |
Context::Scope lock(context); |
- v8::Handle<Value> result = Script::Compile(v8_str("1+3"))->Run(); |
+ v8::Handle<Value> result = CompileRun("1+3"); |
CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
} |
@@ -6681,7 +6667,7 @@ TEST(ExtensionWithSourceLength) { |
Context::New(CcTest::isolate(), &extensions); |
if (source_len == kEmbeddedExtensionSourceValidLen) { |
Context::Scope lock(context); |
- v8::Handle<Value> result = Script::Compile(v8_str("Ret54321()"))->Run(); |
+ v8::Handle<Value> result = CompileRun("Ret54321()"); |
CHECK_EQ(v8::Integer::New(CcTest::isolate(), 54321), result); |
} else { |
// Anything but exactly the right length should fail to compile. |
@@ -6717,9 +6703,9 @@ TEST(UseEvalFromExtension) { |
v8::Handle<Context> context = |
Context::New(CcTest::isolate(), &extensions); |
Context::Scope lock(context); |
- v8::Handle<Value> result = Script::Compile(v8_str("UseEval1()"))->Run(); |
+ v8::Handle<Value> result = CompileRun("UseEval1()"); |
CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
- result = Script::Compile(v8_str("UseEval2()"))->Run(); |
+ result = CompileRun("UseEval2()"); |
CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
} |
@@ -6751,9 +6737,9 @@ TEST(UseWithFromExtension) { |
v8::Handle<Context> context = |
Context::New(CcTest::isolate(), &extensions); |
Context::Scope lock(context); |
- v8::Handle<Value> result = Script::Compile(v8_str("UseWith1()"))->Run(); |
+ v8::Handle<Value> result = CompileRun("UseWith1()"); |
CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
- result = Script::Compile(v8_str("UseWith2()"))->Run(); |
+ result = CompileRun("UseWith2()"); |
CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 87)); |
} |
@@ -6766,7 +6752,7 @@ TEST(AutoExtensions) { |
v8::Handle<Context> context = |
Context::New(CcTest::isolate()); |
Context::Scope lock(context); |
- v8::Handle<Value> result = Script::Compile(v8_str("Foo()"))->Run(); |
+ v8::Handle<Value> result = CompileRun("Foo()"); |
CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 4)); |
} |
@@ -6826,7 +6812,7 @@ TEST(NativeCallInExtensions) { |
v8::Handle<Context> context = |
Context::New(CcTest::isolate(), &extensions); |
Context::Scope lock(context); |
- v8::Handle<Value> result = Script::Compile(v8_str(kNativeCallTest))->Run(); |
+ v8::Handle<Value> result = CompileRun(kNativeCallTest); |
CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 3)); |
} |
@@ -6863,7 +6849,7 @@ TEST(NativeFunctionDeclaration) { |
v8::Handle<Context> context = |
Context::New(CcTest::isolate(), &extensions); |
Context::Scope lock(context); |
- v8::Handle<Value> result = Script::Compile(v8_str("foo(42);"))->Run(); |
+ v8::Handle<Value> result = CompileRun("foo(42);"); |
CHECK_EQ(result, v8::Integer::New(CcTest::isolate(), 42)); |
} |
@@ -6994,11 +6980,11 @@ THREADED_TEST(FunctionLookup) { |
LocalContext context(&config); |
CHECK_EQ(3, lookup_count); |
CHECK_EQ(v8::Integer::New(CcTest::isolate(), 8), |
- Script::Compile(v8_str("Foo(0)"))->Run()); |
+ CompileRun("Foo(0)")); |
CHECK_EQ(v8::Integer::New(CcTest::isolate(), 7), |
- Script::Compile(v8_str("Foo(1)"))->Run()); |
+ CompileRun("Foo(1)")); |
CHECK_EQ(v8::Integer::New(CcTest::isolate(), 6), |
- Script::Compile(v8_str("Foo(2)"))->Run()); |
+ CompileRun("Foo(2)")); |
} |
@@ -7012,11 +6998,11 @@ THREADED_TEST(NativeFunctionConstructCall) { |
// Run a few times to ensure that allocation of objects doesn't |
// change behavior of a constructor function. |
CHECK_EQ(v8::Integer::New(CcTest::isolate(), 8), |
- Script::Compile(v8_str("(new A()).data"))->Run()); |
+ CompileRun("(new A()).data")); |
CHECK_EQ(v8::Integer::New(CcTest::isolate(), 7), |
- Script::Compile(v8_str("(new B()).data"))->Run()); |
+ CompileRun("(new B()).data")); |
CHECK_EQ(v8::Integer::New(CcTest::isolate(), 6), |
- Script::Compile(v8_str("(new C()).data"))->Run()); |
+ CompileRun("(new C()).data")); |
} |
} |
@@ -7062,7 +7048,7 @@ THREADED_TEST(ErrorWithMissingScriptInfo) { |
LocalContext context; |
v8::HandleScope scope(context->GetIsolate()); |
v8::V8::AddMessageListener(MissingScriptInfoMessageListener); |
- Script::Compile(v8_str("throw Error()"))->Run(); |
+ CompileRun("throw Error()"); |
v8::V8::RemoveMessageListeners(MissingScriptInfoMessageListener); |
} |
@@ -7483,7 +7469,7 @@ THREADED_TEST(ObjectInstantiation) { |
CHECK_NE(obj, context->Global()->Get(v8_str("o"))); |
context->Global()->Set(v8_str("o2"), obj); |
v8::Handle<Value> value = |
- Script::Compile(v8_str("o.__proto__ === o2.__proto__"))->Run(); |
+ CompileRun("o.__proto__ === o2.__proto__"); |
CHECK_EQ(v8::True(isolate), value); |
context->Global()->Set(v8_str("o"), obj); |
} |
@@ -8244,13 +8230,14 @@ TEST(ApiUncaughtException) { |
v8::Local<v8::Object> global = env->Global(); |
global->Set(v8_str("trouble"), fun->GetFunction()); |
- Script::Compile(v8_str("function trouble_callee() {" |
- " var x = null;" |
- " return x.foo;" |
- "};" |
- "function trouble_caller() {" |
- " trouble();" |
- "};"))->Run(); |
+ CompileRun( |
+ "function trouble_callee() {" |
+ " var x = null;" |
+ " return x.foo;" |
+ "};" |
+ "function trouble_caller() {" |
+ " trouble();" |
+ "};"); |
Local<Value> trouble = global->Get(v8_str("trouble")); |
CHECK(trouble->IsFunction()); |
Local<Value> trouble_callee = global->Get(v8_str("trouble_callee")); |
@@ -8286,13 +8273,12 @@ TEST(ExceptionInNativeScript) { |
v8::Local<v8::Object> global = env->Global(); |
global->Set(v8_str("trouble"), fun->GetFunction()); |
- Script::Compile( |
- v8_str( |
- "function trouble() {\n" |
- " var o = {};\n" |
- " new o.foo();\n" |
- "};"), |
- v8::String::NewFromUtf8(isolate, script_resource_name))->Run(); |
+ CompileRunWithOrigin( |
+ "function trouble() {\n" |
+ " var o = {};\n" |
+ " new o.foo();\n" |
+ "};", |
+ script_resource_name); |
Local<Value> trouble = global->Get(v8_str("trouble")); |
CHECK(trouble->IsFunction()); |
Function::Cast(*trouble)->Call(global, 0, NULL); |
@@ -8304,7 +8290,7 @@ TEST(CompilationErrorUsingTryCatchHandler) { |
LocalContext env; |
v8::HandleScope scope(env->GetIsolate()); |
v8::TryCatch try_catch; |
- Script::Compile(v8_str("This doesn't &*&@#$&*^ compile.")); |
+ v8_compile("This doesn't &*&@#$&*^ compile."); |
CHECK_NE(NULL, *try_catch.Exception()); |
CHECK(try_catch.HasCaught()); |
} |
@@ -8314,18 +8300,20 @@ TEST(TryCatchFinallyUsingTryCatchHandler) { |
LocalContext env; |
v8::HandleScope scope(env->GetIsolate()); |
v8::TryCatch try_catch; |
- Script::Compile(v8_str("try { throw ''; } catch (e) {}"))->Run(); |
+ CompileRun("try { throw ''; } catch (e) {}"); |
CHECK(!try_catch.HasCaught()); |
- Script::Compile(v8_str("try { throw ''; } finally {}"))->Run(); |
+ CompileRun("try { throw ''; } finally {}"); |
CHECK(try_catch.HasCaught()); |
try_catch.Reset(); |
- Script::Compile(v8_str("(function() {" |
- "try { throw ''; } finally { return; }" |
- "})()"))->Run(); |
+ CompileRun( |
+ "(function() {" |
+ "try { throw ''; } finally { return; }" |
+ "})()"); |
CHECK(!try_catch.HasCaught()); |
- Script::Compile(v8_str("(function()" |
- " { try { throw ''; } finally { throw 0; }" |
- "})()"))->Run(); |
+ CompileRun( |
+ "(function()" |
+ " { try { throw ''; } finally { throw 0; }" |
+ "})()"); |
CHECK(try_catch.HasCaught()); |
} |
@@ -8403,12 +8391,12 @@ THREADED_TEST(SecurityChecks) { |
env1->SetSecurityToken(foo); |
// Create a function in env1. |
- Script::Compile(v8_str("spy=function(){return spy;}"))->Run(); |
+ CompileRun("spy=function(){return spy;}"); |
Local<Value> spy = env1->Global()->Get(v8_str("spy")); |
CHECK(spy->IsFunction()); |
// Create another function accessing global objects. |
- Script::Compile(v8_str("spy2=function(){return new this.Array();}"))->Run(); |
+ CompileRun("spy2=function(){return new this.Array();}"); |
Local<Value> spy2 = env1->Global()->Get(v8_str("spy2")); |
CHECK(spy2->IsFunction()); |
@@ -8521,7 +8509,7 @@ THREADED_TEST(CrossDomainDelete) { |
{ |
Context::Scope scope_env2(env2); |
Local<Value> result = |
- Script::Compile(v8_str("delete env1.prop"))->Run(); |
+ CompileRun("delete env1.prop"); |
CHECK(result->IsFalse()); |
} |
@@ -8551,7 +8539,7 @@ THREADED_TEST(CrossDomainIsPropertyEnumerable) { |
Local<String> test = v8_str("propertyIsEnumerable.call(env1, 'prop')"); |
{ |
Context::Scope scope_env2(env2); |
- Local<Value> result = Script::Compile(test)->Run(); |
+ Local<Value> result = CompileRun(test); |
CHECK(result->IsTrue()); |
} |
@@ -8559,7 +8547,7 @@ THREADED_TEST(CrossDomainIsPropertyEnumerable) { |
env2->SetSecurityToken(bar); |
{ |
Context::Scope scope_env2(env2); |
- Local<Value> result = Script::Compile(test)->Run(); |
+ Local<Value> result = CompileRun(test); |
CHECK(result->IsFalse()); |
} |
} |
@@ -9771,10 +9759,10 @@ THREADED_TEST(InstanceProperties) { |
Local<Value> o = t->GetFunction()->NewInstance(); |
context->Global()->Set(v8_str("i"), o); |
- Local<Value> value = Script::Compile(v8_str("i.x"))->Run(); |
+ Local<Value> value = CompileRun("i.x"); |
CHECK_EQ(42, value->Int32Value()); |
- value = Script::Compile(v8_str("i.f()"))->Run(); |
+ value = CompileRun("i.f()"); |
CHECK_EQ(12, value->Int32Value()); |
} |
@@ -9823,22 +9811,22 @@ THREADED_TEST(GlobalObjectInstanceProperties) { |
// environment initialization. |
global_object = env->Global(); |
- Local<Value> value = Script::Compile(v8_str("x"))->Run(); |
+ Local<Value> value = CompileRun("x"); |
CHECK_EQ(42, value->Int32Value()); |
- value = Script::Compile(v8_str("f()"))->Run(); |
+ value = CompileRun("f()"); |
CHECK_EQ(12, value->Int32Value()); |
- value = Script::Compile(v8_str(script))->Run(); |
+ value = CompileRun(script); |
CHECK_EQ(1, value->Int32Value()); |
} |
{ |
// Create new environment reusing the global object. |
LocalContext env(NULL, instance_template, global_object); |
- Local<Value> value = Script::Compile(v8_str("x"))->Run(); |
+ Local<Value> value = CompileRun("x"); |
CHECK_EQ(42, value->Int32Value()); |
- value = Script::Compile(v8_str("f()"))->Run(); |
+ value = CompileRun("f()"); |
CHECK_EQ(12, value->Int32Value()); |
- value = Script::Compile(v8_str(script))->Run(); |
+ value = CompileRun(script); |
CHECK_EQ(1, value->Int32Value()); |
} |
} |
@@ -9873,14 +9861,14 @@ THREADED_TEST(CallKnownGlobalReceiver) { |
// Hold on to the global object so it can be used again in another |
// environment initialization. |
global_object = env->Global(); |
- foo = Script::Compile(v8_str(script))->Run(); |
+ foo = CompileRun(script); |
} |
{ |
// Create new environment reusing the global object. |
LocalContext env(NULL, instance_template, global_object); |
env->Global()->Set(v8_str("foo"), foo); |
- Script::Compile(v8_str("foo()"))->Run(); |
+ CompileRun("foo()"); |
} |
} |
@@ -9949,19 +9937,19 @@ THREADED_TEST(ShadowObject) { |
context->Global()->Set(v8_str("__proto__"), o); |
Local<Value> value = |
- Script::Compile(v8_str("this.propertyIsEnumerable(0)"))->Run(); |
+ CompileRun("this.propertyIsEnumerable(0)"); |
CHECK(value->IsBoolean()); |
CHECK(!value->BooleanValue()); |
- value = Script::Compile(v8_str("x"))->Run(); |
+ value = CompileRun("x"); |
CHECK_EQ(12, value->Int32Value()); |
- value = Script::Compile(v8_str("f()"))->Run(); |
+ value = CompileRun("f()"); |
CHECK_EQ(42, value->Int32Value()); |
- Script::Compile(v8_str("y = 43"))->Run(); |
+ CompileRun("y = 43"); |
CHECK_EQ(1, shadow_y_setter_call_count); |
- value = Script::Compile(v8_str("y"))->Run(); |
+ value = CompileRun("y"); |
CHECK_EQ(1, shadow_y_getter_call_count); |
CHECK_EQ(42, value->Int32Value()); |
} |
@@ -10585,29 +10573,29 @@ THREADED_TEST(EvalAliasedDynamic) { |
v8::HandleScope scope(current->GetIsolate()); |
// Tests where aliased eval can only be resolved dynamically. |
- Local<Script> script = |
- Script::Compile(v8_str("function f(x) { " |
- " var foo = 2;" |
- " with (x) { return eval('foo'); }" |
- "}" |
- "foo = 0;" |
- "result1 = f(new Object());" |
- "result2 = f(this);" |
- "var x = new Object();" |
- "x.eval = function(x) { return 1; };" |
- "result3 = f(x);")); |
+ Local<Script> script = v8_compile( |
+ "function f(x) { " |
+ " var foo = 2;" |
+ " with (x) { return eval('foo'); }" |
+ "}" |
+ "foo = 0;" |
+ "result1 = f(new Object());" |
+ "result2 = f(this);" |
+ "var x = new Object();" |
+ "x.eval = function(x) { return 1; };" |
+ "result3 = f(x);"); |
script->Run(); |
CHECK_EQ(2, current->Global()->Get(v8_str("result1"))->Int32Value()); |
CHECK_EQ(0, current->Global()->Get(v8_str("result2"))->Int32Value()); |
CHECK_EQ(1, current->Global()->Get(v8_str("result3"))->Int32Value()); |
v8::TryCatch try_catch; |
- script = |
- Script::Compile(v8_str("function f(x) { " |
- " var bar = 2;" |
- " with (x) { return eval('bar'); }" |
- "}" |
- "result4 = f(this)")); |
+ script = v8_compile( |
+ "function f(x) { " |
+ " var bar = 2;" |
+ " with (x) { return eval('bar'); }" |
+ "}" |
+ "result4 = f(this)"); |
script->Run(); |
CHECK(!try_catch.HasCaught()); |
CHECK_EQ(2, current->Global()->Get(v8_str("result4"))->Int32Value()); |
@@ -10629,8 +10617,7 @@ THREADED_TEST(CrossEval) { |
current->Global()->Set(v8_str("other"), other->Global()); |
// Check that new variables are introduced in other context. |
- Local<Script> script = |
- Script::Compile(v8_str("other.eval('var foo = 1234')")); |
+ Local<Script> script = v8_compile("other.eval('var foo = 1234')"); |
script->Run(); |
Local<Value> foo = other->Global()->Get(v8_str("foo")); |
CHECK_EQ(1234, foo->Int32Value()); |
@@ -10638,8 +10625,7 @@ THREADED_TEST(CrossEval) { |
// Check that writing to non-existing properties introduces them in |
// the other context. |
- script = |
- Script::Compile(v8_str("other.eval('na = 1234')")); |
+ script = v8_compile("other.eval('na = 1234')"); |
script->Run(); |
CHECK_EQ(1234, other->Global()->Get(v8_str("na"))->Int32Value()); |
CHECK(!current->Global()->Has(v8_str("na"))); |
@@ -10647,19 +10633,18 @@ THREADED_TEST(CrossEval) { |
// Check that global variables in current context are not visible in other |
// context. |
v8::TryCatch try_catch; |
- script = |
- Script::Compile(v8_str("var bar = 42; other.eval('bar');")); |
+ script = v8_compile("var bar = 42; other.eval('bar');"); |
Local<Value> result = script->Run(); |
CHECK(try_catch.HasCaught()); |
try_catch.Reset(); |
// Check that local variables in current context are not visible in other |
// context. |
- script = |
- Script::Compile(v8_str("(function() { " |
- " var baz = 87;" |
- " return other.eval('baz');" |
- "})();")); |
+ script = v8_compile( |
+ "(function() { " |
+ " var baz = 87;" |
+ " return other.eval('baz');" |
+ "})();"); |
result = script->Run(); |
CHECK(try_catch.HasCaught()); |
try_catch.Reset(); |
@@ -10667,30 +10652,28 @@ THREADED_TEST(CrossEval) { |
// Check that global variables in the other environment are visible |
// when evaluting code. |
other->Global()->Set(v8_str("bis"), v8_num(1234)); |
- script = Script::Compile(v8_str("other.eval('bis')")); |
+ script = v8_compile("other.eval('bis')"); |
CHECK_EQ(1234, script->Run()->Int32Value()); |
CHECK(!try_catch.HasCaught()); |
// Check that the 'this' pointer points to the global object evaluating |
// code. |
other->Global()->Set(v8_str("t"), other->Global()); |
- script = Script::Compile(v8_str("other.eval('this == t')")); |
+ script = v8_compile("other.eval('this == t')"); |
result = script->Run(); |
CHECK(result->IsTrue()); |
CHECK(!try_catch.HasCaught()); |
// Check that variables introduced in with-statement are not visible in |
// other context. |
- script = |
- Script::Compile(v8_str("with({x:2}){other.eval('x')}")); |
+ script = v8_compile("with({x:2}){other.eval('x')}"); |
result = script->Run(); |
CHECK(try_catch.HasCaught()); |
try_catch.Reset(); |
// Check that you cannot use 'eval.call' with another object than the |
// current global object. |
- script = |
- Script::Compile(v8_str("other.y = 1; eval.call(other, 'y')")); |
+ script = v8_compile("other.y = 1; eval.call(other, 'y')"); |
result = script->Run(); |
CHECK(try_catch.HasCaught()); |
} |
@@ -10745,8 +10728,7 @@ THREADED_TEST(CrossLazyLoad) { |
current->Global()->Set(v8_str("other"), other->Global()); |
// Trigger lazy loading in other context. |
- Local<Script> script = |
- Script::Compile(v8_str("other.eval('new Date(42)')")); |
+ Local<Script> script = v8_compile("other.eval('new Date(42)')"); |
Local<Value> value = script->Run(); |
CHECK_EQ(42.0, value->NumberValue()); |
} |
@@ -14250,14 +14232,12 @@ TEST(CatchStackOverflow) { |
LocalContext context; |
v8::HandleScope scope(context->GetIsolate()); |
v8::TryCatch try_catch; |
- v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::NewFromUtf8( |
- context->GetIsolate(), |
+ v8::Handle<v8::Value> result = CompileRun( |
"function f() {" |
" return f();" |
"}" |
"" |
- "f();")); |
- v8::Handle<v8::Value> result = script->Run(); |
+ "f();"); |
CHECK(result.IsEmpty()); |
} |
@@ -14287,8 +14267,7 @@ static void CheckTryCatchSourceInfo(v8::Handle<v8::Script> script, |
THREADED_TEST(TryCatchSourceInfo) { |
LocalContext context; |
v8::HandleScope scope(context->GetIsolate()); |
- v8::Handle<v8::String> source = v8::String::NewFromUtf8( |
- context->GetIsolate(), |
+ v8::Local<v8::String> source = v8_str( |
"function Foo() {\n" |
" return Bar();\n" |
"}\n" |
@@ -14306,8 +14285,7 @@ THREADED_TEST(TryCatchSourceInfo) { |
const char* resource_name; |
v8::Handle<v8::Script> script; |
resource_name = "test.js"; |
- script = v8::Script::Compile( |
- source, v8::String::NewFromUtf8(context->GetIsolate(), resource_name)); |
+ script = CompileWithOrigin(source, resource_name); |
CheckTryCatchSourceInfo(script, resource_name, 0); |
resource_name = "test1.js"; |
@@ -14332,10 +14310,8 @@ THREADED_TEST(CompilationCache) { |
v8::String::NewFromUtf8(context->GetIsolate(), "1234"); |
v8::Handle<v8::String> source1 = |
v8::String::NewFromUtf8(context->GetIsolate(), "1234"); |
- v8::Handle<v8::Script> script0 = v8::Script::Compile( |
- source0, v8::String::NewFromUtf8(context->GetIsolate(), "test.js")); |
- v8::Handle<v8::Script> script1 = v8::Script::Compile( |
- source1, v8::String::NewFromUtf8(context->GetIsolate(), "test.js")); |
+ v8::Handle<v8::Script> script0 = CompileWithOrigin(source0, "test.js"); |
+ v8::Handle<v8::Script> script1 = CompileWithOrigin(source1, "test.js"); |
v8::Handle<v8::Script> script2 = |
v8::Script::Compile(source0); // different origin |
CHECK_EQ(1234, script0->Run()->Int32Value()); |
@@ -14408,8 +14384,7 @@ THREADED_TEST(PropertyEnumeration) { |
LocalContext context; |
v8::Isolate* isolate = context->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( |
- context->GetIsolate(), |
+ v8::Handle<v8::Value> obj = CompileRun( |
"var result = [];" |
"result[0] = {};" |
"result[1] = {a: 1, b: 2};" |
@@ -14417,7 +14392,7 @@ THREADED_TEST(PropertyEnumeration) { |
"var proto = {x: 1, y: 2, z: 3};" |
"var x = { __proto__: proto, w: 0, z: 1 };" |
"result[3] = x;" |
- "result;"))->Run(); |
+ "result;"); |
v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
CHECK_EQ(4, elms->Length()); |
int elmc0 = 0; |
@@ -14453,8 +14428,7 @@ THREADED_TEST(PropertyEnumeration2) { |
LocalContext context; |
v8::Isolate* isolate = context->GetIsolate(); |
v8::HandleScope scope(isolate); |
- v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::NewFromUtf8( |
- context->GetIsolate(), |
+ v8::Handle<v8::Value> obj = CompileRun( |
"var result = [];" |
"result[0] = {};" |
"result[1] = {a: 1, b: 2};" |
@@ -14462,7 +14436,7 @@ THREADED_TEST(PropertyEnumeration2) { |
"var proto = {x: 1, y: 2, z: 3};" |
"var x = { __proto__: proto, w: 0, z: 1 };" |
"result[3] = x;" |
- "result;"))->Run(); |
+ "result;"); |
v8::Handle<v8::Array> elms = obj.As<v8::Array>(); |
CHECK_EQ(4, elms->Length()); |
int elmc0 = 0; |
@@ -16999,7 +16973,7 @@ THREADED_TEST(ScriptContextDependence) { |
v8::HandleScope scope(c1->GetIsolate()); |
const char *source = "foo"; |
v8::Handle<v8::Script> dep = |
- v8::Script::Compile(v8::String::NewFromUtf8(c1->GetIsolate(), source)); |
+ v8_compile(source); |
v8::Handle<v8::Script> indep = |
v8::Script::New(v8::String::NewFromUtf8(c1->GetIsolate(), source)); |
c1->Global()->Set(v8::String::NewFromUtf8(c1->GetIsolate(), "foo"), |
@@ -17176,13 +17150,14 @@ TEST(CaptureStackTraceForUncaughtException) { |
v8::V8::AddMessageListener(StackTraceForUncaughtExceptionListener); |
v8::V8::SetCaptureStackTraceForUncaughtExceptions(true); |
- Script::Compile(v8_str("function foo() {\n" |
- " throw 1;\n" |
- "};\n" |
- "function bar() {\n" |
- " foo();\n" |
- "};"), |
- v8_str("origin"))->Run(); |
+ CompileRunWithOrigin( |
+ "function foo() {\n" |
+ " throw 1;\n" |
+ "};\n" |
+ "function bar() {\n" |
+ " foo();\n" |
+ "};", |
+ "origin"); |
v8::Local<v8::Object> global = env->Global(); |
Local<Value> trouble = global->Get(v8_str("bar")); |
CHECK(trouble->IsFunction()); |
@@ -17417,9 +17392,7 @@ TEST(ScriptIdInStackTrace) { |
" AnalyzeScriptIdInStack();" |
"}\n" |
"foo();\n"); |
- v8::ScriptOrigin origin = |
- v8::ScriptOrigin(v8::String::NewFromUtf8(isolate, "test")); |
- v8::Local<v8::Script> script(v8::Script::Compile(scriptSource, &origin)); |
+ v8::Local<v8::Script> script = CompileWithOrigin(scriptSource, "test"); |
script->Run(); |
for (int i = 0; i < 2; i++) { |
CHECK(scriptIdInStack[i] != v8::Message::kNoScriptIdInfo); |
@@ -18444,14 +18417,14 @@ TEST(SetterOnConstructorPrototype) { |
"C2.prototype.__proto__ = P;"); |
v8::Local<v8::Script> script; |
- script = v8::Script::Compile(v8_str("new C1();")); |
+ script = v8_compile("new C1();"); |
for (int i = 0; i < 10; i++) { |
v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run()); |
CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value()); |
CHECK_EQ(23, c1->Get(v8_str("y"))->Int32Value()); |
} |
- script = v8::Script::Compile(v8_str("new C2();")); |
+script = v8_compile("new C2();"); |
for (int i = 0; i < 10; i++) { |
v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); |
CHECK_EQ(42, c2->Get(v8_str("x"))->Int32Value()); |
@@ -18496,14 +18469,14 @@ THREADED_TEST(InterceptorOnConstructorPrototype) { |
"C2.prototype.__proto__ = P;"); |
v8::Local<v8::Script> script; |
- script = v8::Script::Compile(v8_str("new C1();")); |
+ script = v8_compile("new C1();"); |
for (int i = 0; i < 10; i++) { |
v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run()); |
CHECK_EQ(23, c1->Get(v8_str("x"))->Int32Value()); |
CHECK_EQ(42, c1->Get(v8_str("y"))->Int32Value()); |
} |
- script = v8::Script::Compile(v8_str("new C2();")); |
+ script = v8_compile("new C2();"); |
for (int i = 0; i < 10; i++) { |
v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); |
CHECK_EQ(23, c2->Get(v8_str("x"))->Int32Value()); |
@@ -18531,7 +18504,7 @@ TEST(Regress618) { |
// This compile will add the code to the compilation cache. |
CompileRun(source); |
- script = v8::Script::Compile(v8_str("new C1();")); |
+ script = v8_compile("new C1();"); |
// Allow enough iterations for the inobject slack tracking logic |
// to finalize instance size and install the fast construct stub. |
for (int i = 0; i < 256; i++) { |
@@ -18550,7 +18523,7 @@ TEST(Regress618) { |
// This compile will get the code from the compilation cache. |
CompileRun(source); |
- script = v8::Script::Compile(v8_str("new C1();")); |
+ script = v8_compile("new C1();"); |
for (int i = 0; i < 10; i++) { |
v8::Handle<v8::Object> c1 = v8::Handle<v8::Object>::Cast(script->Run()); |
CHECK_EQ(42, c1->Get(v8_str("x"))->Int32Value()); |