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

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

Issue 1128553002: Add ObjectTemplate::New() taking FunctionTemplate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add ObjectTemplate::New() taking FunctionTemplate. Created 5 years, 7 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
« no previous file with comments | « src/api.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 1764 matching lines...) Expand 10 before | Expand all | Expand 10 after
1775 v8::Handle<Value> result(script->Run()); 1775 v8::Handle<Value> result(script->Run());
1776 CHECK_EQ(13.4, result->NumberValue()); 1776 CHECK_EQ(13.4, result->NumberValue());
1777 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); 1777 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value());
1778 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); 1778 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value());
1779 } 1779 }
1780 1780
1781 1781
1782 THREADED_TEST(ObjectTemplate) { 1782 THREADED_TEST(ObjectTemplate) {
1783 v8::Isolate* isolate = CcTest::isolate(); 1783 v8::Isolate* isolate = CcTest::isolate();
1784 v8::HandleScope scope(isolate); 1784 v8::HandleScope scope(isolate);
1785 Local<ObjectTemplate> templ1 = ObjectTemplate::New(isolate); 1785 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate);
1786 v8::Local<v8::String> class_name =
1787 v8::String::NewFromUtf8(isolate, "the_class_name");
1788 fun->SetClassName(class_name);
1789 Local<ObjectTemplate> templ1 = ObjectTemplate::New(isolate, fun);
1786 templ1->Set(isolate, "x", v8_num(10)); 1790 templ1->Set(isolate, "x", v8_num(10));
1787 templ1->Set(isolate, "y", v8_num(13)); 1791 templ1->Set(isolate, "y", v8_num(13));
1788 LocalContext env; 1792 LocalContext env;
1789 Local<v8::Object> instance1 = templ1->NewInstance(); 1793 Local<v8::Object> instance1 = templ1->NewInstance();
1794 CHECK(class_name->StrictEquals(instance1->GetConstructorName()));
1790 env->Global()->Set(v8_str("p"), instance1); 1795 env->Global()->Set(v8_str("p"), instance1);
1791 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue()); 1796 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue());
1792 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue()); 1797 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue());
1793 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(isolate); 1798 Local<v8::FunctionTemplate> fun2 = v8::FunctionTemplate::New(isolate);
1794 fun->PrototypeTemplate()->Set(isolate, "nirk", v8_num(123)); 1799 fun2->PrototypeTemplate()->Set(isolate, "nirk", v8_num(123));
1795 Local<ObjectTemplate> templ2 = fun->InstanceTemplate(); 1800 Local<ObjectTemplate> templ2 = fun2->InstanceTemplate();
1796 templ2->Set(isolate, "a", v8_num(12)); 1801 templ2->Set(isolate, "a", v8_num(12));
1797 templ2->Set(isolate, "b", templ1); 1802 templ2->Set(isolate, "b", templ1);
1798 Local<v8::Object> instance2 = templ2->NewInstance(); 1803 Local<v8::Object> instance2 = templ2->NewInstance();
1799 env->Global()->Set(v8_str("q"), instance2); 1804 env->Global()->Set(v8_str("q"), instance2);
1800 CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue()); 1805 CHECK(v8_compile("(q.nirk == 123)")->Run()->BooleanValue());
1801 CHECK(v8_compile("(q.a == 12)")->Run()->BooleanValue()); 1806 CHECK(v8_compile("(q.a == 12)")->Run()->BooleanValue());
1802 CHECK(v8_compile("(q.b.x == 10)")->Run()->BooleanValue()); 1807 CHECK(v8_compile("(q.b.x == 10)")->Run()->BooleanValue());
1803 CHECK(v8_compile("(q.b.y == 13)")->Run()->BooleanValue()); 1808 CHECK(v8_compile("(q.b.y == 13)")->Run()->BooleanValue());
1804 } 1809 }
1805 1810
(...skipping 19199 matching lines...) Expand 10 before | Expand all | Expand 10 after
21005 21010
21006 { 21011 {
21007 v8::HandleScope handle_scope(isolate); 21012 v8::HandleScope handle_scope(isolate);
21008 21013
21009 // Should work 21014 // Should work
21010 v8::Local<v8::Object> obj = v8::Object::New(isolate); 21015 v8::Local<v8::Object> obj = v8::Object::New(isolate);
21011 21016
21012 USE(obj); 21017 USE(obj);
21013 } 21018 }
21014 } 21019 }
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698