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

Side by Side Diff: test/cctest/test-api.cc

Issue 660169: Add test of internal fields on global objects. This test currently... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 10 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. 1 // Copyright 2007-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); 1327 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
1328 instance_templ->SetInternalFieldCount(1); 1328 instance_templ->SetInternalFieldCount(1);
1329 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); 1329 Local<v8::Object> obj = templ->GetFunction()->NewInstance();
1330 CHECK_EQ(1, obj->InternalFieldCount()); 1330 CHECK_EQ(1, obj->InternalFieldCount());
1331 CHECK(obj->GetInternalField(0)->IsUndefined()); 1331 CHECK(obj->GetInternalField(0)->IsUndefined());
1332 obj->SetInternalField(0, v8_num(17)); 1332 obj->SetInternalField(0, v8_num(17));
1333 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value()); 1333 CHECK_EQ(17, obj->GetInternalField(0)->Int32Value());
1334 } 1334 }
1335 1335
1336 1336
1337 THREADED_TEST(GlobalObjectInternalFields) {
1338 v8::HandleScope scope;
1339 Local<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
1340 global_template->SetInternalFieldCount(1);
1341 LocalContext env(NULL, global_template);
1342 v8::Handle<v8::Object> global_proxy = env->Global();
1343 v8::Handle<v8::Object> global =
1344 v8::Handle<v8::Object>::Cast(global_proxy->GetPrototype());
1345 CHECK_EQ(1, global->InternalFieldCount());
1346 CHECK(global->GetInternalField(0)->IsUndefined());
1347 global->SetInternalField(0, v8_num(17));
1348 CHECK_EQ(17, global->GetInternalField(0)->Int32Value());
1349 }
1350
1351
1337 THREADED_TEST(InternalFieldsNativePointers) { 1352 THREADED_TEST(InternalFieldsNativePointers) {
1338 v8::HandleScope scope; 1353 v8::HandleScope scope;
1339 LocalContext env; 1354 LocalContext env;
1340 1355
1341 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); 1356 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
1342 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate(); 1357 Local<v8::ObjectTemplate> instance_templ = templ->InstanceTemplate();
1343 instance_templ->SetInternalFieldCount(1); 1358 instance_templ->SetInternalFieldCount(1);
1344 Local<v8::Object> obj = templ->GetFunction()->NewInstance(); 1359 Local<v8::Object> obj = templ->GetFunction()->NewInstance();
1345 CHECK_EQ(1, obj->InternalFieldCount()); 1360 CHECK_EQ(1, obj->InternalFieldCount());
1346 CHECK(obj->GetPointerFromInternalField(0) == NULL); 1361 CHECK(obj->GetPointerFromInternalField(0) == NULL);
(...skipping 8442 matching lines...) Expand 10 before | Expand all | Expand 10 after
9789 CHECK_EQ(42, c1->Get(v8_str("y"))->Int32Value()); 9804 CHECK_EQ(42, c1->Get(v8_str("y"))->Int32Value());
9790 } 9805 }
9791 9806
9792 script = v8::Script::Compile(v8_str("new C2();")); 9807 script = v8::Script::Compile(v8_str("new C2();"));
9793 for (int i = 0; i < 10; i++) { 9808 for (int i = 0; i < 10; i++) {
9794 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run()); 9809 v8::Handle<v8::Object> c2 = v8::Handle<v8::Object>::Cast(script->Run());
9795 CHECK_EQ(23, c2->Get(v8_str("x"))->Int32Value()); 9810 CHECK_EQ(23, c2->Get(v8_str("x"))->Int32Value());
9796 CHECK_EQ(42, c2->Get(v8_str("y"))->Int32Value()); 9811 CHECK_EQ(42, c2->Get(v8_str("y"))->Int32Value());
9797 } 9812 }
9798 } 9813 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698