| OLD | NEW |
| 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 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 template<typename Handler> | 1008 template<typename Handler> |
| 1009 static void TestFunctionTemplateInitializer(Handler handler, | 1009 static void TestFunctionTemplateInitializer(Handler handler, |
| 1010 Handler handler_2) { | 1010 Handler handler_2) { |
| 1011 // Test constructor calls. | 1011 // Test constructor calls. |
| 1012 { | 1012 { |
| 1013 LocalContext env; | 1013 LocalContext env; |
| 1014 v8::HandleScope scope(env->GetIsolate()); | 1014 v8::HandleScope scope(env->GetIsolate()); |
| 1015 | 1015 |
| 1016 Local<v8::FunctionTemplate> fun_templ = | 1016 Local<v8::FunctionTemplate> fun_templ = |
| 1017 v8::FunctionTemplate::New(handler); | 1017 v8::FunctionTemplate::New(handler); |
| 1018 ASSERT_EQ(fun_templ->GetIsolate(), env->GetIsolate()); |
| 1018 Local<Function> fun = fun_templ->GetFunction(); | 1019 Local<Function> fun = fun_templ->GetFunction(); |
| 1019 env->Global()->Set(v8_str("obj"), fun); | 1020 env->Global()->Set(v8_str("obj"), fun); |
| 1020 Local<Script> script = v8_compile("obj()"); | 1021 Local<Script> script = v8_compile("obj()"); |
| 1021 for (int i = 0; i < 30; i++) { | 1022 for (int i = 0; i < 30; i++) { |
| 1022 CHECK_EQ(102, script->Run()->Int32Value()); | 1023 CHECK_EQ(102, script->Run()->Int32Value()); |
| 1023 } | 1024 } |
| 1024 } | 1025 } |
| 1025 // Use SetCallHandler to initialize a function template, should work like | 1026 // Use SetCallHandler to initialize a function template, should work like |
| 1026 // the previous one. | 1027 // the previous one. |
| 1027 { | 1028 { |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1754 LocalContext env(0, templ); | 1755 LocalContext env(0, templ); |
| 1755 v8::Handle<Script> script(v8_compile("dummy()")); | 1756 v8::Handle<Script> script(v8_compile("dummy()")); |
| 1756 v8::Handle<Value> result(script->Run()); | 1757 v8::Handle<Value> result(script->Run()); |
| 1757 CHECK_EQ(13.4, result->NumberValue()); | 1758 CHECK_EQ(13.4, result->NumberValue()); |
| 1758 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); | 1759 CHECK_EQ(200, v8_compile("x")->Run()->Int32Value()); |
| 1759 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); | 1760 CHECK_EQ(876, v8_compile("m")->Run()->Int32Value()); |
| 1760 } | 1761 } |
| 1761 | 1762 |
| 1762 | 1763 |
| 1763 THREADED_TEST(ObjectTemplate) { | 1764 THREADED_TEST(ObjectTemplate) { |
| 1764 v8::HandleScope scope(CcTest::isolate()); | 1765 v8::Isolate* isolate = CcTest::isolate(); |
| 1766 v8::HandleScope scope(isolate); |
| 1765 Local<ObjectTemplate> templ1 = ObjectTemplate::New(); | 1767 Local<ObjectTemplate> templ1 = ObjectTemplate::New(); |
| 1768 ASSERT_EQ(templ1->GetIsolate(), isolate); |
| 1766 templ1->Set("x", v8_num(10)); | 1769 templ1->Set("x", v8_num(10)); |
| 1767 templ1->Set("y", v8_num(13)); | 1770 templ1->Set("y", v8_num(13)); |
| 1768 LocalContext env; | 1771 LocalContext env; |
| 1769 Local<v8::Object> instance1 = templ1->NewInstance(); | 1772 Local<v8::Object> instance1 = templ1->NewInstance(); |
| 1770 env->Global()->Set(v8_str("p"), instance1); | 1773 env->Global()->Set(v8_str("p"), instance1); |
| 1771 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue()); | 1774 CHECK(v8_compile("(p.x == 10)")->Run()->BooleanValue()); |
| 1772 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue()); | 1775 CHECK(v8_compile("(p.y == 13)")->Run()->BooleanValue()); |
| 1773 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); | 1776 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(); |
| 1774 fun->PrototypeTemplate()->Set("nirk", v8_num(123)); | 1777 fun->PrototypeTemplate()->Set("nirk", v8_num(123)); |
| 1775 Local<ObjectTemplate> templ2 = fun->InstanceTemplate(); | 1778 Local<ObjectTemplate> templ2 = fun->InstanceTemplate(); |
| (...skipping 18963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20739 } | 20742 } |
| 20740 for (int i = 0; i < runs; i++) { | 20743 for (int i = 0; i < runs; i++) { |
| 20741 Local<String> expected; | 20744 Local<String> expected; |
| 20742 if (i != 0) { | 20745 if (i != 0) { |
| 20743 CHECK_EQ(v8_str("escape value"), values[i]); | 20746 CHECK_EQ(v8_str("escape value"), values[i]); |
| 20744 } else { | 20747 } else { |
| 20745 CHECK(values[i].IsEmpty()); | 20748 CHECK(values[i].IsEmpty()); |
| 20746 } | 20749 } |
| 20747 } | 20750 } |
| 20748 } | 20751 } |
| OLD | NEW |