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

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

Issue 1049703002: Make compilers agree on source position of thrown errors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix another regression. Created 5 years, 8 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/prettyprinter.cc ('k') | test/message/regress/regress-3995.js » ('j') | 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 5294 matching lines...) Expand 10 before | Expand all | Expand 10 after
5305 5305
5306 5306
5307 void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) { 5307 void TryCatchMixedNestingCheck(v8::TryCatch* try_catch) {
5308 CHECK(try_catch->HasCaught()); 5308 CHECK(try_catch->HasCaught());
5309 Handle<Message> message = try_catch->Message(); 5309 Handle<Message> message = try_catch->Message();
5310 Handle<Value> resource = message->GetScriptOrigin().ResourceName(); 5310 Handle<Value> resource = message->GetScriptOrigin().ResourceName();
5311 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner")); 5311 CHECK_EQ(0, strcmp(*v8::String::Utf8Value(resource), "inner"));
5312 CHECK_EQ(0, 5312 CHECK_EQ(0,
5313 strcmp(*v8::String::Utf8Value(message->Get()), "Uncaught Error: a")); 5313 strcmp(*v8::String::Utf8Value(message->Get()), "Uncaught Error: a"));
5314 CHECK_EQ(1, message->GetLineNumber()); 5314 CHECK_EQ(1, message->GetLineNumber());
5315 // TODO(3995): Our compilers disagree about the position. 5315 CHECK_EQ(0, message->GetStartColumn());
5316 if (!i::FLAG_always_opt) CHECK_EQ(6, message->GetStartColumn());
5317 } 5316 }
5318 5317
5319 5318
5320 void TryCatchMixedNestingHelper( 5319 void TryCatchMixedNestingHelper(
5321 const v8::FunctionCallbackInfo<v8::Value>& args) { 5320 const v8::FunctionCallbackInfo<v8::Value>& args) {
5322 ApiTestFuzzer::Fuzz(); 5321 ApiTestFuzzer::Fuzz();
5323 v8::TryCatch try_catch; 5322 v8::TryCatch try_catch;
5324 CompileRunWithOrigin("throw new Error('a');\n", "inner", 0, 0); 5323 CompileRunWithOrigin("throw new Error('a');\n", "inner", 0, 0);
5325 CHECK(try_catch.HasCaught()); 5324 CHECK(try_catch.HasCaught());
5326 TryCatchMixedNestingCheck(&try_catch); 5325 TryCatchMixedNestingCheck(&try_catch);
(...skipping 4461 matching lines...) Expand 10 before | Expand all | Expand 10 after
9788 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate); 9787 Local<ObjectTemplate> instance_template = ObjectTemplate::New(isolate);
9789 Local<Object> instance = instance_template->NewInstance(); 9788 Local<Object> instance = instance_template->NewInstance();
9790 context->Global()->Set(v8_str("obj2"), instance); 9789 context->Global()->Set(v8_str("obj2"), instance);
9791 v8::TryCatch try_catch; 9790 v8::TryCatch try_catch;
9792 Local<Value> value; 9791 Local<Value> value;
9793 CHECK(!try_catch.HasCaught()); 9792 CHECK(!try_catch.HasCaught());
9794 9793
9795 value = CompileRun("new obj2(28)"); 9794 value = CompileRun("new obj2(28)");
9796 CHECK(try_catch.HasCaught()); 9795 CHECK(try_catch.HasCaught());
9797 String::Utf8Value exception_value1(try_catch.Exception()); 9796 String::Utf8Value exception_value1(try_catch.Exception());
9798 // TODO(3995): Our compilers disagree about the position (and message). 9797 CHECK_EQ(0, strcmp("TypeError: obj2 is not a function", *exception_value1));
9799 if (!i::FLAG_always_opt) {
9800 CHECK_EQ(0,
9801 strcmp("TypeError: obj2 is not a function", *exception_value1));
9802 }
9803 try_catch.Reset(); 9798 try_catch.Reset();
9804 9799
9805 Local<Value> args[] = {v8_num(29)}; 9800 Local<Value> args[] = {v8_num(29)};
9806 value = instance->CallAsConstructor(1, args); 9801 value = instance->CallAsConstructor(1, args);
9807 CHECK(try_catch.HasCaught()); 9802 CHECK(try_catch.HasCaught());
9808 String::Utf8Value exception_value2(try_catch.Exception()); 9803 String::Utf8Value exception_value2(try_catch.Exception());
9809 CHECK_EQ( 9804 CHECK_EQ(
9810 0, strcmp("TypeError: #<Object> is not a function", *exception_value2)); 9805 0, strcmp("TypeError: #<Object> is not a function", *exception_value2));
9811 try_catch.Reset(); 9806 try_catch.Reset();
9812 } 9807 }
(...skipping 5185 matching lines...) Expand 10 before | Expand all | Expand 10 after
14998 int testGroup = args[0]->Int32Value(); 14993 int testGroup = args[0]->Int32Value();
14999 if (testGroup == kOverviewTest) { 14994 if (testGroup == kOverviewTest) {
15000 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( 14995 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
15001 args.GetIsolate(), 10, v8::StackTrace::kOverview); 14996 args.GetIsolate(), 10, v8::StackTrace::kOverview);
15002 CHECK_EQ(4, stackTrace->GetFrameCount()); 14997 CHECK_EQ(4, stackTrace->GetFrameCount());
15003 checkStackFrame(origin, "bar", 2, 10, false, false, 14998 checkStackFrame(origin, "bar", 2, 10, false, false,
15004 stackTrace->GetFrame(0)); 14999 stackTrace->GetFrame(0));
15005 checkStackFrame(origin, "foo", 6, 3, false, false, 15000 checkStackFrame(origin, "foo", 6, 3, false, false,
15006 stackTrace->GetFrame(1)); 15001 stackTrace->GetFrame(1));
15007 // This is the source string inside the eval which has the call to foo. 15002 // This is the source string inside the eval which has the call to foo.
15008 checkStackFrame(NULL, "", 1, 5, false, false, 15003 checkStackFrame(NULL, "", 1, 1, false, false, stackTrace->GetFrame(2));
15009 stackTrace->GetFrame(2));
15010 // The last frame is an anonymous function which has the initial eval call. 15004 // The last frame is an anonymous function which has the initial eval call.
15011 checkStackFrame(origin, "", 8, 7, false, false, 15005 checkStackFrame(origin, "", 8, 7, false, false, stackTrace->GetFrame(3));
15012 stackTrace->GetFrame(3));
15013 15006
15014 CHECK(stackTrace->AsArray()->IsArray()); 15007 CHECK(stackTrace->AsArray()->IsArray());
15015 } else if (testGroup == kDetailedTest) { 15008 } else if (testGroup == kDetailedTest) {
15016 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( 15009 v8::Handle<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace(
15017 args.GetIsolate(), 10, v8::StackTrace::kDetailed); 15010 args.GetIsolate(), 10, v8::StackTrace::kDetailed);
15018 CHECK_EQ(4, stackTrace->GetFrameCount()); 15011 CHECK_EQ(4, stackTrace->GetFrameCount());
15019 checkStackFrame(origin, "bat", 4, 22, false, false, 15012 checkStackFrame(origin, "bat", 4, 22, false, false,
15020 stackTrace->GetFrame(0)); 15013 stackTrace->GetFrame(0));
15021 checkStackFrame(origin, "baz", 8, 3, false, true, 15014 checkStackFrame(origin, "baz", 8, 3, false, true,
15022 stackTrace->GetFrame(1)); 15015 stackTrace->GetFrame(1));
15023 bool is_eval = true; 15016 bool is_eval = true;
15024 // This is the source string inside the eval which has the call to baz. 15017 // This is the source string inside the eval which has the call to baz.
15025 checkStackFrame(NULL, "", 1, 5, is_eval, false, 15018 checkStackFrame(NULL, "", 1, 1, is_eval, false, stackTrace->GetFrame(2));
15026 stackTrace->GetFrame(2));
15027 // The last frame is an anonymous function which has the initial eval call. 15019 // The last frame is an anonymous function which has the initial eval call.
15028 checkStackFrame(origin, "", 10, 1, false, false, 15020 checkStackFrame(origin, "", 10, 1, false, false, stackTrace->GetFrame(3));
15029 stackTrace->GetFrame(3));
15030 15021
15031 CHECK(stackTrace->AsArray()->IsArray()); 15022 CHECK(stackTrace->AsArray()->IsArray());
15032 } 15023 }
15033 } 15024 }
15034 15025
15035 15026
15036 // Tests the C++ StackTrace API. 15027 // Tests the C++ StackTrace API.
15037 // TODO(3074796): Reenable this as a THREADED_TEST once it passes. 15028 // TODO(3074796): Reenable this as a THREADED_TEST once it passes.
15038 // THREADED_TEST(CaptureStackTrace) { 15029 // THREADED_TEST(CaptureStackTrace) {
15039 TEST(CaptureStackTrace) { 15030 TEST(CaptureStackTrace) {
(...skipping 6853 matching lines...) Expand 10 before | Expand all | Expand 10 after
21893 } 21884 }
21894 { 21885 {
21895 v8::TryCatch try_catch; 21886 v8::TryCatch try_catch;
21896 uint16_t* data = reinterpret_cast<uint16_t*>(buffer); 21887 uint16_t* data = reinterpret_cast<uint16_t*>(buffer);
21897 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString, 21888 CHECK(v8::String::NewFromTwoByte(isolate, data, v8::String::kNormalString,
21898 length).IsEmpty()); 21889 length).IsEmpty());
21899 CHECK(!try_catch.HasCaught()); 21890 CHECK(!try_catch.HasCaught());
21900 } 21891 }
21901 free(buffer); 21892 free(buffer);
21902 } 21893 }
OLDNEW
« no previous file with comments | « src/prettyprinter.cc ('k') | test/message/regress/regress-3995.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698