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 11335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11346 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); | 11346 { Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); |
11347 Local<Object> instance = instance_template->NewInstance(); | 11347 Local<Object> instance = instance_template->NewInstance(); |
11348 context->Global()->Set(v8_str("obj2"), instance); | 11348 context->Global()->Set(v8_str("obj2"), instance); |
11349 v8::TryCatch try_catch; | 11349 v8::TryCatch try_catch; |
11350 Local<Value> value; | 11350 Local<Value> value; |
11351 CHECK(!try_catch.HasCaught()); | 11351 CHECK(!try_catch.HasCaught()); |
11352 | 11352 |
11353 value = CompileRun("new obj2(28)"); | 11353 value = CompileRun("new obj2(28)"); |
11354 CHECK(try_catch.HasCaught()); | 11354 CHECK(try_catch.HasCaught()); |
11355 String::Utf8Value exception_value1(try_catch.Exception()); | 11355 String::Utf8Value exception_value1(try_catch.Exception()); |
11356 CHECK_EQ("TypeError: object is not a function", *exception_value1); | 11356 CHECK_EQ("TypeError: obj2 is not a function", *exception_value1); |
11357 try_catch.Reset(); | 11357 try_catch.Reset(); |
11358 | 11358 |
11359 Local<Value> args[] = { v8_num(29) }; | 11359 Local<Value> args[] = { v8_num(29) }; |
11360 value = instance->CallAsConstructor(1, args); | 11360 value = instance->CallAsConstructor(1, args); |
11361 CHECK(try_catch.HasCaught()); | 11361 CHECK(try_catch.HasCaught()); |
11362 String::Utf8Value exception_value2(try_catch.Exception()); | 11362 String::Utf8Value exception_value2(try_catch.Exception()); |
11363 CHECK_EQ("TypeError: #<Object> is not a function", *exception_value2); | 11363 CHECK_EQ("TypeError: #<Object> is not a function", *exception_value2); |
11364 try_catch.Reset(); | 11364 try_catch.Reset(); |
11365 } | 11365 } |
11366 | 11366 |
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11707 v8::TryCatch try_catch; | 11707 v8::TryCatch try_catch; |
11708 Local<Value> value; | 11708 Local<Value> value; |
11709 CHECK(!try_catch.HasCaught()); | 11709 CHECK(!try_catch.HasCaught()); |
11710 | 11710 |
11711 // Call an object without call-as-function handler through the JS | 11711 // Call an object without call-as-function handler through the JS |
11712 value = CompileRun("obj2(28)"); | 11712 value = CompileRun("obj2(28)"); |
11713 CHECK(value.IsEmpty()); | 11713 CHECK(value.IsEmpty()); |
11714 CHECK(try_catch.HasCaught()); | 11714 CHECK(try_catch.HasCaught()); |
11715 String::Utf8Value exception_value1(try_catch.Exception()); | 11715 String::Utf8Value exception_value1(try_catch.Exception()); |
11716 // TODO(verwaest): Better message | 11716 // TODO(verwaest): Better message |
11717 CHECK_EQ("TypeError: object is not a function", | 11717 CHECK_EQ("TypeError: obj2 is not a function", *exception_value1); |
11718 *exception_value1); | |
11719 try_catch.Reset(); | 11718 try_catch.Reset(); |
11720 | 11719 |
11721 // Call an object without call-as-function handler through the API | 11720 // Call an object without call-as-function handler through the API |
11722 value = CompileRun("obj2(28)"); | 11721 value = CompileRun("obj2(28)"); |
11723 v8::Handle<Value> args[] = { v8_num(28) }; | 11722 v8::Handle<Value> args[] = { v8_num(28) }; |
11724 value = instance->CallAsFunction(instance, 1, args); | 11723 value = instance->CallAsFunction(instance, 1, args); |
11725 CHECK(value.IsEmpty()); | 11724 CHECK(value.IsEmpty()); |
11726 CHECK(try_catch.HasCaught()); | 11725 CHECK(try_catch.HasCaught()); |
11727 String::Utf8Value exception_value2(try_catch.Exception()); | 11726 String::Utf8Value exception_value2(try_catch.Exception()); |
11728 CHECK_EQ("TypeError: [object Object] is not a function", *exception_value2); | 11727 CHECK_EQ("TypeError: [object Object] is not a function", *exception_value2); |
(...skipping 1359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13088 "var saved_result = 0;" | 13087 "var saved_result = 0;" |
13089 "for (var i = 0; i < 100; i++) {" | 13088 "for (var i = 0; i < 100; i++) {" |
13090 " result = receiver.method(41);" | 13089 " result = receiver.method(41);" |
13091 " if (i == 50) {" | 13090 " if (i == 50) {" |
13092 " saved_result = result;" | 13091 " saved_result = result;" |
13093 " receiver = 333;" | 13092 " receiver = 333;" |
13094 " }" | 13093 " }" |
13095 "}"); | 13094 "}"); |
13096 CHECK(try_catch.HasCaught()); | 13095 CHECK(try_catch.HasCaught()); |
13097 // TODO(verwaest): Adjust message. | 13096 // TODO(verwaest): Adjust message. |
13098 CHECK_EQ(v8_str("TypeError: undefined is not a function"), | 13097 CHECK_EQ(v8_str("TypeError: receiver.method is not a function"), |
13099 try_catch.Exception()->ToString(isolate)); | 13098 try_catch.Exception()->ToString(isolate)); |
13100 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 13099 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
13101 CHECK_GE(interceptor_call_count, 50); | 13100 CHECK_GE(interceptor_call_count, 50); |
13102 } | 13101 } |
13103 | 13102 |
13104 | 13103 |
13105 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { | 13104 THREADED_PROFILED_TEST(InterceptorCallICFastApi_SimpleSignature_TypeError) { |
13106 int interceptor_call_count = 0; | 13105 int interceptor_call_count = 0; |
13107 v8::Isolate* isolate = CcTest::isolate(); | 13106 v8::Isolate* isolate = CcTest::isolate(); |
13108 v8::HandleScope scope(isolate); | 13107 v8::HandleScope scope(isolate); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13263 "var saved_result = 0;" | 13262 "var saved_result = 0;" |
13264 "for (var i = 0; i < 100; i++) {" | 13263 "for (var i = 0; i < 100; i++) {" |
13265 " result = receiver.method(41);" | 13264 " result = receiver.method(41);" |
13266 " if (i == 50) {" | 13265 " if (i == 50) {" |
13267 " saved_result = result;" | 13266 " saved_result = result;" |
13268 " receiver = 333;" | 13267 " receiver = 333;" |
13269 " }" | 13268 " }" |
13270 "}"); | 13269 "}"); |
13271 CHECK(try_catch.HasCaught()); | 13270 CHECK(try_catch.HasCaught()); |
13272 // TODO(verwaest): Adjust message. | 13271 // TODO(verwaest): Adjust message. |
13273 CHECK_EQ(v8_str("TypeError: undefined is not a function"), | 13272 CHECK_EQ(v8_str("TypeError: receiver.method is not a function"), |
13274 try_catch.Exception()->ToString(isolate)); | 13273 try_catch.Exception()->ToString(isolate)); |
13275 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); | 13274 CHECK_EQ(42, context->Global()->Get(v8_str("saved_result"))->Int32Value()); |
13276 } | 13275 } |
13277 | 13276 |
13278 | 13277 |
13279 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { | 13278 THREADED_PROFILED_TEST(CallICFastApi_SimpleSignature_TypeError) { |
13280 v8::Isolate* isolate = CcTest::isolate(); | 13279 v8::Isolate* isolate = CcTest::isolate(); |
13281 v8::HandleScope scope(isolate); | 13280 v8::HandleScope scope(isolate); |
13282 v8::Handle<v8::FunctionTemplate> fun_templ = | 13281 v8::Handle<v8::FunctionTemplate> fun_templ = |
13283 v8::FunctionTemplate::New(isolate); | 13282 v8::FunctionTemplate::New(isolate); |
(...skipping 11413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
24697 "bar2.js"); | 24696 "bar2.js"); |
24698 } | 24697 } |
24699 | 24698 |
24700 | 24699 |
24701 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { | 24700 TEST(StreamingScriptWithSourceMappingURLInTheMiddle) { |
24702 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", | 24701 const char* chunks[] = {"function foo() { ret", "urn 13; }\n//#", |
24703 " sourceMappingURL=bar2.js\n", "foo();", NULL}; | 24702 " sourceMappingURL=bar2.js\n", "foo();", NULL}; |
24704 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, | 24703 RunStreamingTest(chunks, v8::ScriptCompiler::StreamedSource::UTF8, true, NULL, |
24705 "bar2.js"); | 24704 "bar2.js"); |
24706 } | 24705 } |
OLD | NEW |