Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1313)

Unified Diff: test/cctest/test-api.cc

Issue 11415046: Change deprecated semantics of function template signatures. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Ported to ARM. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index f9880bdaee4b75e2b1b9659a59d9e2bda4e95ca4..b4d157a703f2fcf594990b8b8d693e7efbdfbb65 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -8063,12 +8063,8 @@ THREADED_TEST(ShadowObject) {
Local<ObjectTemplate> proto = t->PrototypeTemplate();
Local<ObjectTemplate> instance = t->InstanceTemplate();
- // Only allow calls of f on instances of t.
- Local<v8::Signature> signature = v8::Signature::New(t);
proto->Set(v8_str("f"),
- v8::FunctionTemplate::New(ShadowFunctionCallback,
- Local<Value>(),
- signature));
+ v8::FunctionTemplate::New(ShadowFunctionCallback, Local<Value>()));
proto->Set(v8_str("x"), v8_num(12));
instance->SetAccessor(v8_str("y"), ShadowYGetter, ShadowYSetter);
@@ -9773,7 +9769,7 @@ static v8::Handle<Value> FastApiCallback_SimpleSignature(
ApiTestFuzzer::Fuzz();
v8::Isolate* isolate = v8::Isolate::GetCurrent();
CHECK_EQ(isolate, args.GetIsolate());
- CHECK_EQ(args.This()->GetPrototype(), args.Holder());
+ CHECK_EQ(args.This(), args.Holder());
CHECK(args.Data()->Equals(v8_str("method_data")));
// Note, we're using HasRealNamedProperty instead of Has to avoid
// invoking the interceptor again.
@@ -9923,6 +9919,7 @@ THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) {
CHECK_EQ(100, interceptor_call_count);
}
+
THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) {
int interceptor_call_count = 0;
v8::HandleScope scope;
@@ -9943,8 +9940,7 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) {
context->Global()->Set(v8_str("o"), fun->NewInstance());
CompileRun(
"o.foo = 17;"
- "var receiver = {};"
- "receiver.__proto__ = o;"
+ "var receiver = o;"
rossberg 2012/11/20 11:00:09 Nit: if you want, remove 'receiver' altogether.
"var result = 0;"
"for (var i = 0; i < 100; i++) {"
" result = receiver.method(41);"
@@ -9953,6 +9949,7 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature) {
CHECK_EQ(100, interceptor_call_count);
}
+
THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
int interceptor_call_count = 0;
v8::HandleScope scope;
@@ -9973,8 +9970,7 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
context->Global()->Set(v8_str("o"), fun->NewInstance());
CompileRun(
"o.foo = 17;"
- "var receiver = {};"
- "receiver.__proto__ = o;"
+ "var receiver = o;"
"var result = 0;"
"var saved_result = 0;"
"for (var i = 0; i < 100; i++) {"
@@ -9989,6 +9985,7 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss1) {
CHECK_GE(interceptor_call_count, 50);
}
+
THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
int interceptor_call_count = 0;
v8::HandleScope scope;
@@ -10007,25 +10004,30 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss2) {
v8::Handle<v8::Function> fun = fun_templ->GetFunction();
GenerateSomeGarbage();
context->Global()->Set(v8_str("o"), fun->NewInstance());
+ v8::TryCatch try_catch;
CompileRun(
"o.foo = 17;"
- "var receiver = {};"
- "receiver.__proto__ = o;"
+ "var receiver = o;"
"var result = 0;"
"var saved_result = 0;"
"for (var i = 0; i < 100; i++) {"
" result = receiver.method(41);"
" if (i == 50) {"
" saved_result = result;"
- " o.method = function(x) { return x - 1 };"
+ " result = 0;"
+ " receiver = 333;"
" }"
"}");
- CHECK_EQ(40, context->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK(try_catch.HasCaught());
+ CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"),
+ try_catch.Exception()->ToString());
+ CHECK_EQ(0, context->Global()->Get(v8_str("result"))->Int32Value());
CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
CHECK_GE(interceptor_call_count, 50);
}
-THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
+
+THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError1) {
int interceptor_call_count = 0;
v8::HandleScope scope;
v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
@@ -10046,25 +10048,27 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_Miss3) {
v8::TryCatch try_catch;
CompileRun(
"o.foo = 17;"
- "var receiver = {};"
- "receiver.__proto__ = o;"
+ "var receiver = o;"
"var result = 0;"
- "var saved_result = 0;"
"for (var i = 0; i < 100; i++) {"
- " result = receiver.method(41);"
" if (i == 50) {"
" saved_result = result;"
- " receiver = 333;"
+ " result = 0;"
+ " receiver = {};"
+ " receiver.__proto__ = o;"
" }"
+ " result = receiver.method(41);"
"}");
CHECK(try_catch.HasCaught());
- CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"),
+ CHECK_EQ(v8_str("TypeError: Illegal invocation"),
try_catch.Exception()->ToString());
+ CHECK_EQ(0, context->Global()->Get(v8_str("result"))->Int32Value());
CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
CHECK_GE(interceptor_call_count, 50);
}
-THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
+
+THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError2) {
int interceptor_call_count = 0;
v8::HandleScope scope;
v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
@@ -10085,24 +10089,26 @@ THREADED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) {
v8::TryCatch try_catch;
CompileRun(
"o.foo = 17;"
- "var receiver = {};"
- "receiver.__proto__ = o;"
+ "var receiver = o;"
"var result = 0;"
"var saved_result = 0;"
"for (var i = 0; i < 100; i++) {"
" result = receiver.method(41);"
" if (i == 50) {"
" saved_result = result;"
+ " result = 0;"
" receiver = {method: receiver.method};"
" }"
"}");
CHECK(try_catch.HasCaught());
CHECK_EQ(v8_str("TypeError: Illegal invocation"),
try_catch.Exception()->ToString());
+ CHECK_EQ(0, context->Global()->Get(v8_str("result"))->Int32Value());
CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
CHECK_GE(interceptor_call_count, 50);
}
+
THREADED_TEST(CallICFastApi_TrivialSignature) {
v8::HandleScope scope;
v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
@@ -10127,6 +10133,7 @@ THREADED_TEST(CallICFastApi_TrivialSignature) {
CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
}
+
THREADED_TEST(CallICFastApi_SimpleSignature) {
v8::HandleScope scope;
v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
@@ -10144,8 +10151,7 @@ THREADED_TEST(CallICFastApi_SimpleSignature) {
context->Global()->Set(v8_str("o"), fun->NewInstance());
CompileRun(
"o.foo = 17;"
- "var receiver = {};"
- "receiver.__proto__ = o;"
+ "var receiver = o;"
rossberg 2012/11/20 11:00:09 Ditto.
"var result = 0;"
"for (var i = 0; i < 100; i++) {"
" result = receiver.method(41);"
@@ -10154,6 +10160,7 @@ THREADED_TEST(CallICFastApi_SimpleSignature) {
CHECK_EQ(42, context->Global()->Get(v8_str("result"))->Int32Value());
}
+
THREADED_TEST(CallICFastApi_SimpleSignature_Miss1) {
v8::HandleScope scope;
v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
@@ -10171,8 +10178,7 @@ THREADED_TEST(CallICFastApi_SimpleSignature_Miss1) {
context->Global()->Set(v8_str("o"), fun->NewInstance());
CompileRun(
"o.foo = 17;"
- "var receiver = {};"
- "receiver.__proto__ = o;"
+ "var receiver = o;"
"var result = 0;"
"var saved_result = 0;"
"for (var i = 0; i < 100; i++) {"
@@ -10186,6 +10192,7 @@ THREADED_TEST(CallICFastApi_SimpleSignature_Miss1) {
CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
}
+
THREADED_TEST(CallICFastApi_SimpleSignature_Miss2) {
v8::HandleScope scope;
v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
@@ -10204,20 +10211,59 @@ THREADED_TEST(CallICFastApi_SimpleSignature_Miss2) {
v8::TryCatch try_catch;
CompileRun(
"o.foo = 17;"
- "var receiver = {};"
- "receiver.__proto__ = o;"
+ "var receiver = o;"
"var result = 0;"
"var saved_result = 0;"
"for (var i = 0; i < 100; i++) {"
" result = receiver.method(41);"
" if (i == 50) {"
" saved_result = result;"
+ " result = 0;"
" receiver = 333;"
" }"
"}");
CHECK(try_catch.HasCaught());
CHECK_EQ(v8_str("TypeError: Object 333 has no method 'method'"),
try_catch.Exception()->ToString());
+ CHECK_EQ(0, context->Global()->Get(v8_str("result"))->Int32Value());
+ CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
+}
+
+
+THREADED_TEST(CallICFastApi_SimpleSignature_TypeError) {
+ v8::HandleScope scope;
+ v8::Handle<v8::FunctionTemplate> fun_templ = v8::FunctionTemplate::New();
+ v8::Handle<v8::FunctionTemplate> method_templ =
+ v8::FunctionTemplate::New(FastApiCallback_SimpleSignature,
+ v8_str("method_data"),
+ v8::Signature::New(fun_templ));
+ v8::Handle<v8::ObjectTemplate> proto_templ = fun_templ->PrototypeTemplate();
+ proto_templ->Set(v8_str("method"), method_templ);
+ v8::Handle<v8::ObjectTemplate> templ(fun_templ->InstanceTemplate());
+ CHECK(!templ.IsEmpty());
+ LocalContext context;
+ v8::Handle<v8::Function> fun = fun_templ->GetFunction();
+ GenerateSomeGarbage();
+ context->Global()->Set(v8_str("o"), fun->NewInstance());
+ v8::TryCatch try_catch;
+ CompileRun(
+ "o.foo = 17;"
+ "var receiver = o;"
+ "var result = 0;"
+ "var saved_result = 0;"
+ "for (var i = 0; i < 100; i++) {"
+ " result = receiver.method(41);"
+ " if (i == 50) {"
+ " saved_result = result;"
+ " result = 0;"
+ " receiver = {};"
+ " receiver.__proto__ = o;"
+ " }"
+ "}");
+ CHECK(try_catch.HasCaught());
+ CHECK_EQ(v8_str("TypeError: Illegal invocation"),
+ try_catch.Exception()->ToString());
+ CHECK_EQ(0, context->Global()->Get(v8_str("result"))->Int32Value());
CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value());
}
« no previous file with comments | « src/x64/stub-cache-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698