| Index: test/cctest/test-accessors.cc
|
| diff --git a/test/cctest/test-accessors.cc b/test/cctest/test-accessors.cc
|
| index 7d96ea64c2e77b858ce542dd13d50b559ae492e1..f952b8b163543d83df518ac5eefd12d6bfb2feeb 100644
|
| --- a/test/cctest/test-accessors.cc
|
| +++ b/test/cctest/test-accessors.cc
|
| @@ -51,17 +51,34 @@ static void handle_property(Local<String> name,
|
| }
|
|
|
|
|
| +static void handle_property(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
| + ApiTestFuzzer::Fuzz();
|
| + CHECK_EQ(0, info.Length());
|
| + info.GetReturnValue().Set(v8_num(907));
|
| +}
|
| +
|
| +
|
| THREADED_TEST(PropertyHandler) {
|
| LocalContext env;
|
| v8::HandleScope scope(env->GetIsolate());
|
| Local<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
|
| fun_templ->InstanceTemplate()->SetAccessor(v8_str("foo"), handle_property);
|
| + Local<v8::FunctionTemplate> getter_templ =
|
| + v8::FunctionTemplate::New(handle_property);
|
| + getter_templ->SetLength(0);
|
| + fun_templ->InstanceTemplate()->SetJsAccessor(env->GetIsolate(),
|
| + v8_str("bar"),
|
| + getter_templ);
|
| Local<Function> fun = fun_templ->GetFunction();
|
| env->Global()->Set(v8_str("Fun"), fun);
|
| Local<Script> getter = v8_compile("var obj = new Fun(); obj.foo;");
|
| CHECK_EQ(900, getter->Run()->Int32Value());
|
| Local<Script> setter = v8_compile("obj.foo = 901;");
|
| CHECK_EQ(901, setter->Run()->Int32Value());
|
| + getter = v8_compile("obj.bar;");
|
| + CHECK_EQ(907, getter->Run()->Int32Value());
|
| + setter = v8_compile("obj.bar = 908;");
|
| + CHECK_EQ(908, setter->Run()->Int32Value());
|
| }
|
|
|
|
|
| @@ -109,30 +126,52 @@ THREADED_TEST(GlobalVariableAccess) {
|
| }
|
|
|
|
|
| -static int x_register = 0;
|
| +static int x_register[2] = {0, 0};
|
| static v8::Handle<v8::Object> x_receiver;
|
| static v8::Handle<v8::Object> x_holder;
|
|
|
| -
|
| -static void XGetter(Local<String> name,
|
| - const v8::PropertyCallbackInfo<v8::Value>& info) {
|
| +template<class Info>
|
| +static void XGetter(const Info& info, int offset) {
|
| ApiTestFuzzer::Fuzz();
|
| v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| CHECK_EQ(isolate, info.GetIsolate());
|
| CHECK_EQ(x_receiver, info.This());
|
| + info.GetReturnValue().Set(v8_num(x_register[offset]));
|
| +}
|
| +
|
| +
|
| +static void XGetter(Local<String> name,
|
| + const v8::PropertyCallbackInfo<v8::Value>& info) {
|
| CHECK_EQ(x_holder, info.Holder());
|
| - info.GetReturnValue().Set(v8_num(x_register));
|
| + XGetter(info, 0);
|
| }
|
|
|
|
|
| -static void XSetter(Local<String> name,
|
| - Local<Value> value,
|
| - const v8::PropertyCallbackInfo<void>& info) {
|
| +static void XGetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
| + XGetter(info, 1);
|
| +}
|
| +
|
| +
|
| +template<class Info>
|
| +static void XSetter(Local<Value> value, const Info& info, int offset) {
|
| v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
| CHECK_EQ(isolate, info.GetIsolate());
|
| CHECK_EQ(x_holder, info.This());
|
| + x_register[offset] = value->Int32Value();
|
| +}
|
| +
|
| +
|
| +static void XSetter(Local<String> name,
|
| + Local<Value> value,
|
| + const v8::PropertyCallbackInfo<void>& info) {
|
| CHECK_EQ(x_holder, info.Holder());
|
| - x_register = value->Int32Value();
|
| + XSetter(value, info, 0);
|
| +}
|
| +
|
| +
|
| +static void XSetter(const v8::FunctionCallbackInfo<v8::Value>& info) {
|
| + CHECK_EQ(1, info.Length());
|
| + XSetter(info[0], info, 1);
|
| }
|
|
|
|
|
| @@ -140,7 +179,11 @@ THREADED_TEST(AccessorIC) {
|
| LocalContext context;
|
| v8::HandleScope scope(context->GetIsolate());
|
| v8::Handle<v8::ObjectTemplate> obj = ObjectTemplate::New();
|
| - obj->SetAccessor(v8_str("x"), XGetter, XSetter);
|
| + obj->SetAccessor(v8_str("x0"), XGetter, XSetter);
|
| + obj->SetJsAccessor(context->GetIsolate(),
|
| + v8_str("x1"),
|
| + v8::FunctionTemplate::New(XGetter),
|
| + v8::FunctionTemplate::New(XSetter));
|
| x_holder = obj->NewInstance();
|
| context->Global()->Set(v8_str("holder"), x_holder);
|
| x_receiver = v8::Object::New();
|
| @@ -149,14 +192,16 @@ THREADED_TEST(AccessorIC) {
|
| "obj.__proto__ = holder;"
|
| "var result = [];"
|
| "for (var i = 0; i < 10; i++) {"
|
| - " holder.x = i;"
|
| - " result.push(obj.x);"
|
| + " holder.x0 = i;"
|
| + " holder.x1 = i;"
|
| + " result.push(obj.x0);"
|
| + " result.push(obj.x1);"
|
| "}"
|
| "result"));
|
| - CHECK_EQ(10, array->Length());
|
| - for (int i = 0; i < 10; i++) {
|
| + CHECK_EQ(20, array->Length());
|
| + for (int i = 0; i < 20; i++) {
|
| v8::Handle<Value> entry = array->Get(v8::Integer::New(i));
|
| - CHECK_EQ(v8::Integer::New(i), entry);
|
| + CHECK_EQ(v8::Integer::New(i/2), entry);
|
| }
|
| }
|
|
|
|
|