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 9777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9788 value = CompileRun("new obj2(28)"); | 9788 value = CompileRun("new obj2(28)"); |
9789 CHECK(try_catch.HasCaught()); | 9789 CHECK(try_catch.HasCaught()); |
9790 String::Utf8Value exception_value1(try_catch.Exception()); | 9790 String::Utf8Value exception_value1(try_catch.Exception()); |
9791 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); | 9791 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); |
9792 try_catch.Reset(); | 9792 try_catch.Reset(); |
9793 | 9793 |
9794 Local<Value> args[] = {v8_num(29)}; | 9794 Local<Value> args[] = {v8_num(29)}; |
9795 value = instance->CallAsConstructor(1, args); | 9795 value = instance->CallAsConstructor(1, args); |
9796 CHECK(try_catch.HasCaught()); | 9796 CHECK(try_catch.HasCaught()); |
9797 String::Utf8Value exception_value2(try_catch.Exception()); | 9797 String::Utf8Value exception_value2(try_catch.Exception()); |
9798 CHECK_EQ( | 9798 CHECK_EQ(0, |
9799 0, strcmp("TypeError: #<Object> is not a function", *exception_value2)); | 9799 strcmp("TypeError: object is not a function", *exception_value2)); |
9800 try_catch.Reset(); | 9800 try_catch.Reset(); |
9801 } | 9801 } |
9802 | 9802 |
9803 // Check the case when constructor throws exception. | 9803 // Check the case when constructor throws exception. |
9804 { | 9804 { |
9805 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 9805 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |
9806 instance_template->SetCallAsFunctionHandler(ThrowValue); | 9806 instance_template->SetCallAsFunctionHandler(ThrowValue); |
9807 Local<Object> instance = instance_template->NewInstance(); | 9807 Local<Object> instance = instance_template->NewInstance(); |
9808 context->Global()->Set(v8_str("obj3"), instance); | 9808 context->Global()->Set(v8_str("obj3"), instance); |
9809 v8::TryCatch try_catch(isolate); | 9809 v8::TryCatch try_catch(isolate); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10158 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); | 10158 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1)); |
10159 try_catch.Reset(); | 10159 try_catch.Reset(); |
10160 | 10160 |
10161 // Call an object without call-as-function handler through the API | 10161 // Call an object without call-as-function handler through the API |
10162 value = CompileRun("obj2(28)"); | 10162 value = CompileRun("obj2(28)"); |
10163 v8::Handle<Value> args[] = {v8_num(28)}; | 10163 v8::Handle<Value> args[] = {v8_num(28)}; |
10164 value = instance->CallAsFunction(instance, 1, args); | 10164 value = instance->CallAsFunction(instance, 1, args); |
10165 CHECK(value.IsEmpty()); | 10165 CHECK(value.IsEmpty()); |
10166 CHECK(try_catch.HasCaught()); | 10166 CHECK(try_catch.HasCaught()); |
10167 String::Utf8Value exception_value2(try_catch.Exception()); | 10167 String::Utf8Value exception_value2(try_catch.Exception()); |
10168 CHECK_EQ(0, strcmp("TypeError: [object Object] is not a function", | 10168 CHECK_EQ(0, |
10169 *exception_value2)); | 10169 strcmp("TypeError: object is not a function", *exception_value2)); |
10170 try_catch.Reset(); | 10170 try_catch.Reset(); |
10171 } | 10171 } |
10172 | 10172 |
10173 { | 10173 { |
10174 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); | 10174 Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); |
10175 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); | 10175 Local<ObjectTemplate> instance_template = t->InstanceTemplate(); |
10176 instance_template->SetCallAsFunctionHandler(ThrowValue); | 10176 instance_template->SetCallAsFunctionHandler(ThrowValue); |
10177 Local<v8::Object> instance = t->GetFunction()->NewInstance(); | 10177 Local<v8::Object> instance = t->GetFunction()->NewInstance(); |
10178 context->Global()->Set(v8_str("obj3"), instance); | 10178 context->Global()->Set(v8_str("obj3"), instance); |
10179 v8::TryCatch try_catch(isolate); | 10179 v8::TryCatch try_catch(isolate); |
(...skipping 11672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21852 timeout_thread.Join(); | 21852 timeout_thread.Join(); |
21853 } | 21853 } |
21854 | 21854 |
21855 | 21855 |
21856 TEST(EstimatedContextSize) { | 21856 TEST(EstimatedContextSize) { |
21857 v8::Isolate* isolate = CcTest::isolate(); | 21857 v8::Isolate* isolate = CcTest::isolate(); |
21858 v8::HandleScope scope(isolate); | 21858 v8::HandleScope scope(isolate); |
21859 LocalContext env; | 21859 LocalContext env; |
21860 CHECK(50000 < env->EstimatedSize()); | 21860 CHECK(50000 < env->EstimatedSize()); |
21861 } | 21861 } |
OLD | NEW |