Reviewers: domenic, jochen,
Description:
Add extras test for calling into runtime.
The alternative of passing an object template at context creation is
unfeasible because we need to context to instantiate the template.
At the time we create the context from snapshot or bootstrap from
scratch, we would already need that template instance, leading to a
chicken-and-egg problem.
This is an alternative that is simpler and less intrusive.
[email protected], [email protected]
Please review this at https://codereview.chromium.org/1182443002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+21, -3 lines):
M test/cctest/test-api.cc
M test/cctest/test-extra.js
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
849833e58018e9714ff82228bacfdaf138461993..2fd67d834685b35494f5c539c7981e9e189d5811
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -21445,21 +21445,35 @@ TEST(StrongObjectDelete) {
}
+static void ExtrasExportsTestRuntimeFunction(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ CHECK_EQ(3, args[0]->Int32Value());
+ args.GetReturnValue().Set(v8_num(7));
+}
+
+
TEST(ExtrasExportsObject) {
v8::Isolate* isolate = CcTest::isolate();
v8::HandleScope handle_scope(isolate);
LocalContext env;
// standalone.gypi ensures we include the test-extra.js file, which
should
- // add the testExtraShouldReturnFive export
+ // export the tested functions.
v8::Local<v8::Object> exports = env->GetExtrasExportsObject();
auto func =
exports->Get(v8_str("testExtraShouldReturnFive")).As<v8::Function>();
auto undefined = v8::Undefined(isolate);
auto result = func->Call(undefined, 0, {}).As<v8::Number>();
-
- CHECK(result->Value() == 5.0);
+ CHECK_EQ(5, result->Int32Value());
+
+ v8::Handle<v8::FunctionTemplate> runtimeFunction =
+ v8::FunctionTemplate::New(isolate, ExtrasExportsTestRuntimeFunction);
+ exports->Set(v8_str("runtime"), runtimeFunction->GetFunction());
+ func =
+
exports->Get(v8_str("testExtraShouldCallToRuntime")).As<v8::Function>();
+ result = func->Call(undefined, 0, {}).As<v8::Number>();
+ CHECK_EQ(7, result->Int32Value());
}
Index: test/cctest/test-extra.js
diff --git a/test/cctest/test-extra.js b/test/cctest/test-extra.js
index
9c63d9c103836a714ab48f420d62c62fea44cb78..829ddee01a4c140aacbfa9ca4969daae9ad7929d
100644
--- a/test/cctest/test-extra.js
+++ b/test/cctest/test-extra.js
@@ -7,4 +7,8 @@
exports.testExtraShouldReturnFive = function () {
return 5;
};
+
+ exports.testExtraShouldCallToRuntime = function() {
+ return exports.runtime(3);
+ };
})
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.