Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index 9539973693b10cb0fd5e0e5546c41e762737ba7a..a70eeec493a5480aa607bb3b7494778037cf38cf 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -814,6 +814,39 @@ THREADED_TEST(FunctionTemplate) { |
} |
+static v8::Handle<v8::Value> callback(const v8::Arguments& args) { |
+ int* value = reinterpret_cast<int*>(v8::External::Unwrap(args.Data())); |
+ CHECK_EQ(42, *value); |
+ return v8::Integer::New(*value); |
+} |
+ |
+ |
+THREADED_TEST(PointerAsData) { |
+ v8::HandleScope scope; |
+ LocalContext env; |
+ |
+ int* value = new int; |
+ *value = 42; |
Lasse Reichstein
2011/01/13 12:57:57
Try storing both values that can and can't be stor
antonm
2011/01/13 15:49:15
Done.
|
+ v8::Handle<v8::Value> data = v8::External::Wrap(value); |
+ |
+ v8::Handle<v8::Object> obj = v8::Object::New(); |
+ obj->Set(v8_str("func"), |
+ v8::FunctionTemplate::New(callback, data)->GetFunction()); |
+ env->Global()->Set(v8_str("obj"), obj); |
+ |
+ CHECK(CompileRun( |
+ "function foo() {\n" |
+ " for (var i = 0; i < 13; i++) {\n" |
+ " if (42 != obj.func()) throw 'oops';\n" |
+ " }\n" |
+ " return true;\n" |
+ "}\n" |
+ "foo(), true")->BooleanValue()); |
+ |
+ delete value; |
+} |
+ |
+ |
THREADED_TEST(FindInstanceInPrototypeChain) { |
v8::HandleScope scope; |
LocalContext env; |