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

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

Issue 7331035: Implement API functions for handling the AccessorDescriptor (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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 | « src/handles.cc ('k') | 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 6961 matching lines...) Expand 10 before | Expand all | Expand 10 after
6972 x->Get(v8_str("get")); 6972 x->Get(v8_str("get"));
6973 x->Set(v8_str("set"), v8::Integer::New(8)); 6973 x->Set(v8_str("set"), v8::Integer::New(8));
6974 x->Get(v8_str("get")); 6974 x->Get(v8_str("get"));
6975 x->Set(v8_str("set"), v8::Integer::New(8)); 6975 x->Set(v8_str("set"), v8::Integer::New(8));
6976 x->Get(v8_str("get")); 6976 x->Get(v8_str("get"));
6977 x->Set(v8_str("set"), v8::Integer::New(8)); 6977 x->Set(v8_str("set"), v8::Integer::New(8));
6978 x->Get(v8_str("get")); 6978 x->Get(v8_str("get"));
6979 } 6979 }
6980 6980
6981 6981
6982 THREADED_TEST(DefineAndLookupGetterSetter) {
6983 v8::HandleScope handle_scope;
6984 LocalContext context;
6985 v8::Handle<v8::Object> global = context->Global();
6986
6987 CompileRun("function getter() { return 'getter'; }");
6988 Local<Function> getter = Local<Function>::Cast(global->Get(v8_str("getter")));
6989 CompileRun("function setter() { return 'setter'; }");
6990 Local<Function> setter = Local<Function>::Cast(global->Get(v8_str("setter")));
6991
6992 Local<Object> obj = Object::New();
6993 obj->DefineGetter(v8_str("getter"), getter);
6994 obj->DefineSetter(v8_str("setter"), setter);
6995 context->Global()->Set(String::New("obj"), obj);
6996
6997 CompileRun("d_getter = Object.getOwnPropertyDescriptor(obj, 'getter');"
6998 "d_setter = Object.getOwnPropertyDescriptor(obj, 'setter');");
6999
7000 Local<Value> res = CompileRun("d_getter.get()");
7001 String::AsciiValue string_value1(res);
7002 CHECK_EQ("getter", *string_value1);
7003 Local<Value> f1 = obj->LookupGetter(v8_str("getter"));
7004 Local<Value> res2 = Local<Function>::Cast(f1)->Call(obj, 0, NULL);
7005 String::AsciiValue string_value2(res2);
7006 CHECK_EQ("getter", *string_value2);
7007
7008 Local<Value> res3 = CompileRun("d_getter.set");
7009 CHECK(res3->IsUndefined());
7010 Local<Value> res4 = obj->LookupSetter(v8_str("getter"));
7011 CHECK(res4->IsUndefined());
7012
7013 Local<Value> res5 = CompileRun("d_setter.get");
7014 CHECK(res5->IsUndefined());
7015 Local<Value> res6 = obj->LookupGetter(v8_str("setter"));
7016 CHECK(res6->IsUndefined());
7017
7018 Local<Value> res7 = CompileRun("d_setter.set()");
7019 String::AsciiValue string_value3(res7);
7020 CHECK_EQ("setter", *string_value3);
7021 Local<Value> f2 = obj->LookupSetter(v8_str("setter"));
7022 Local<Value> res8 = Local<Function>::Cast(f2)->Call(obj, 0, NULL);
7023 String::AsciiValue string_value4(res8);
7024 CHECK_EQ("setter", *string_value4);
7025
7026 CompileRun("function getter2() { return 'getter2'; }");
7027 Local<Function> getter2 =
7028 Local<Function>::Cast(global->Get(v8_str("getter2")));
7029 obj->DefineGetter(v8_str("getter"), getter2);
7030 CompileRun("d_getter = Object.getOwnPropertyDescriptor(obj, 'getter');");
7031 Local<Value> res9 = CompileRun("d_getter.get()");
7032 String::AsciiValue string_value5(res9);
7033 CHECK_EQ("getter2", *string_value5);
7034 Local<Value> f3 = obj->LookupGetter(v8_str("getter"));
7035 Local<Value> res10 = Local<Function>::Cast(f3)->Call(obj, 0, NULL);
7036 String::AsciiValue string_value6(res10);
7037 CHECK_EQ("getter2", *string_value6);
7038
7039 CompileRun("function setter2() { return 'setter2'; }");
7040 Local<Function> setter2 =
7041 Local<Function>::Cast(global->Get(v8_str("setter2")));
7042 obj->DefineSetter(v8_str("setter"), setter2);
7043 CompileRun("d_setter = Object.getOwnPropertyDescriptor(obj, 'setter');");
7044 Local<Value> res11 = CompileRun("d_setter.set()");
7045 String::AsciiValue string_value7(res11);
7046 CHECK_EQ("setter2", *string_value7);
7047 Local<Value> f4 = obj->LookupSetter(v8_str("setter"));
7048 Local<Value> res12 = Local<Function>::Cast(f4)->Call(obj, 0, NULL);
7049 String::AsciiValue string_value8(res12);
7050 CHECK_EQ("setter2", *string_value8);
7051 }
7052
7053
6982 THREADED_TEST(Constructor) { 7054 THREADED_TEST(Constructor) {
6983 v8::HandleScope handle_scope; 7055 v8::HandleScope handle_scope;
6984 LocalContext context; 7056 LocalContext context;
6985 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New(); 7057 Local<v8::FunctionTemplate> templ = v8::FunctionTemplate::New();
6986 templ->SetClassName(v8_str("Fun")); 7058 templ->SetClassName(v8_str("Fun"));
6987 Local<Function> cons = templ->GetFunction(); 7059 Local<Function> cons = templ->GetFunction();
6988 context->Global()->Set(v8_str("Fun"), cons); 7060 context->Global()->Set(v8_str("Fun"), cons);
6989 Local<v8::Object> inst = cons->NewInstance(); 7061 Local<v8::Object> inst = cons->NewInstance();
6990 i::Handle<i::JSObject> obj = v8::Utils::OpenHandle(*inst); 7062 i::Handle<i::JSObject> obj = v8::Utils::OpenHandle(*inst);
6991 Local<Value> value = CompileRun("(new Fun()).constructor === Fun"); 7063 Local<Value> value = CompileRun("(new Fun()).constructor === Fun");
(...skipping 7685 matching lines...) Expand 10 before | Expand all | Expand 10 after
14677 } 14749 }
14678 14750
14679 i::Isolate::Current()->heap()->CollectAllGarbage(true); 14751 i::Isolate::Current()->heap()->CollectAllGarbage(true);
14680 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache(); 14752 { i::Object* raw_map_cache = i::Isolate::Current()->context()->map_cache();
14681 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) { 14753 if (raw_map_cache != i::Isolate::Current()->heap()->undefined_value()) {
14682 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache); 14754 i::MapCache* map_cache = i::MapCache::cast(raw_map_cache);
14683 CHECK_GT(elements, map_cache->NumberOfElements()); 14755 CHECK_GT(elements, map_cache->NumberOfElements());
14684 } 14756 }
14685 } 14757 }
14686 } 14758 }
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698