| Index: test/cctest/test-compiler.cc
|
| diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc
|
| index 6efab9963f5d1bc4afc23fc433896a47f11d382f..faf533239e504b0b411c49b6f97175b50653faf6 100644
|
| --- a/test/cctest/test-compiler.cc
|
| +++ b/test/cctest/test-compiler.cc
|
| @@ -416,7 +416,7 @@ TEST(CompileFunctionInContext) {
|
| "x = r * cos(PI);"
|
| "y = r * sin(PI / 2);"));
|
| v8::Local<v8::Function> fun = v8::ScriptCompiler::CompileFunctionInContext(
|
| - CcTest::isolate(), &script_source, env.local(), 1, &math);
|
| + CcTest::isolate(), &script_source, env.local(), 0, NULL, 1, &math);
|
| CHECK(!fun.IsEmpty());
|
| fun->Call(env->Global(), 0, NULL);
|
| CHECK(env->Global()->Has(v8_str("a")));
|
| @@ -449,7 +449,7 @@ TEST(CompileFunctionInContextComplex) {
|
| ext[1] = v8::Local<v8::Object>::Cast(env->Global()->Get(v8_str("b")));
|
| v8::ScriptCompiler::Source script_source(v8_str("result = x + y + z"));
|
| v8::Local<v8::Function> fun = v8::ScriptCompiler::CompileFunctionInContext(
|
| - CcTest::isolate(), &script_source, env.local(), 2, ext);
|
| + CcTest::isolate(), &script_source, env.local(), 0, NULL, 2, ext);
|
| CHECK(!fun.IsEmpty());
|
| fun->Call(env->Global(), 0, NULL);
|
| CHECK(env->Global()->Has(v8_str("result")));
|
| @@ -459,6 +459,61 @@ TEST(CompileFunctionInContextComplex) {
|
| }
|
|
|
|
|
| +TEST(CompileFunctionInContextArgs) {
|
| + CcTest::InitializeVM();
|
| + v8::HandleScope scope(CcTest::isolate());
|
| + LocalContext env;
|
| + CompileRun("var a = {x: 23};");
|
| + v8::Local<v8::Object> ext[1];
|
| + ext[0] = v8::Local<v8::Object>::Cast(env->Global()->Get(v8_str("a")));
|
| + v8::ScriptCompiler::Source script_source(v8_str("result = x + b"));
|
| + v8::Local<v8::String> arg = v8_str("b");
|
| + v8::Local<v8::Function> fun = v8::ScriptCompiler::CompileFunctionInContext(
|
| + CcTest::isolate(), &script_source, env.local(), 1, &arg, 1, ext);
|
| + CHECK(!fun.IsEmpty());
|
| + v8::Local<v8::Value> b_value = v8::Number::New(CcTest::isolate(), 42.0);
|
| + fun->Call(env->Global(), 1, &b_value);
|
| + CHECK(env->Global()->Has(v8_str("result")));
|
| + v8::Local<v8::Value> result = env->Global()->Get(v8_str("result"));
|
| + CHECK(result->IsNumber());
|
| + CHECK_EQ(65.0, result->NumberValue());
|
| +}
|
| +
|
| +
|
| +TEST(CompileFunctionInContextComments) {
|
| + CcTest::InitializeVM();
|
| + v8::HandleScope scope(CcTest::isolate());
|
| + LocalContext env;
|
| + CompileRun("var a = {x: 23, y: 1, z: 2};");
|
| + v8::Local<v8::Object> ext[1];
|
| + ext[0] = v8::Local<v8::Object>::Cast(env->Global()->Get(v8_str("a")));
|
| + v8::ScriptCompiler::Source script_source(
|
| + v8_str("result = /* y + */ x + b // + z"));
|
| + v8::Local<v8::String> arg = v8_str("b");
|
| + v8::Local<v8::Function> fun = v8::ScriptCompiler::CompileFunctionInContext(
|
| + CcTest::isolate(), &script_source, env.local(), 1, &arg, 1, ext);
|
| + CHECK(!fun.IsEmpty());
|
| + v8::Local<v8::Value> b_value = v8::Number::New(CcTest::isolate(), 42.0);
|
| + fun->Call(env->Global(), 1, &b_value);
|
| + CHECK(env->Global()->Has(v8_str("result")));
|
| + v8::Local<v8::Value> result = env->Global()->Get(v8_str("result"));
|
| + CHECK(result->IsNumber());
|
| + CHECK_EQ(65.0, result->NumberValue());
|
| +}
|
| +
|
| +
|
| +TEST(CompileFunctionInContextNonIdentifierArgs) {
|
| + CcTest::InitializeVM();
|
| + v8::HandleScope scope(CcTest::isolate());
|
| + LocalContext env;
|
| + v8::ScriptCompiler::Source script_source(v8_str("result = 1"));
|
| + v8::Local<v8::String> arg = v8_str("b }");
|
| + v8::Local<v8::Function> fun = v8::ScriptCompiler::CompileFunctionInContext(
|
| + CcTest::isolate(), &script_source, env.local(), 1, &arg, 0, NULL);
|
| + CHECK(fun.IsEmpty());
|
| +}
|
| +
|
| +
|
| #ifdef ENABLE_DISASSEMBLER
|
| static Handle<JSFunction> GetJSFunction(v8::Handle<v8::Object> obj,
|
| const char* property_name) {
|
|
|