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

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

Issue 12945: Pull out revision 915 and 916 to get a green builder. I believe the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years 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 | Annotate | Revision Log
« no previous file with comments | « src/top.cc ('k') | test/message/try-catch-finally-return-in-finally.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 2007-2008 the V8 project authors. All rights reserved. 1 // Copyright 2007-2008 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 2942 matching lines...) Expand 10 before | Expand all | Expand 10 after
2953 static int report_count = 0; 2953 static int report_count = 0;
2954 static void ApiUncaughtExceptionTestListener(v8::Handle<v8::Message>, 2954 static void ApiUncaughtExceptionTestListener(v8::Handle<v8::Message>,
2955 v8::Handle<Value>) { 2955 v8::Handle<Value>) {
2956 report_count++; 2956 report_count++;
2957 } 2957 }
2958 2958
2959 2959
2960 // Counts uncaught exceptions, but other tests running in parallel 2960 // Counts uncaught exceptions, but other tests running in parallel
2961 // also have uncaught exceptions. 2961 // also have uncaught exceptions.
2962 TEST(ApiUncaughtException) { 2962 TEST(ApiUncaughtException) {
2963 report_count = 0;
2964 v8::HandleScope scope; 2963 v8::HandleScope scope;
2965 LocalContext env; 2964 LocalContext env;
2966 v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener); 2965 v8::V8::AddMessageListener(ApiUncaughtExceptionTestListener);
2967 2966
2968 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback); 2967 Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(TroubleCallback);
2969 v8::Local<v8::Object> global = env->Global(); 2968 v8::Local<v8::Object> global = env->Global();
2970 global->Set(v8_str("trouble"), fun->GetFunction()); 2969 global->Set(v8_str("trouble"), fun->GetFunction());
2971 2970
2972 Script::Compile(v8_str("function trouble_callee() {" 2971 Script::Compile(v8_str("function trouble_callee() {"
2973 " var x = null;" 2972 " var x = null;"
2974 " return x.foo;" 2973 " return x.foo;"
2975 "};" 2974 "};"
2976 "function trouble_caller() {" 2975 "function trouble_caller() {"
2977 " trouble();" 2976 " trouble();"
2978 "};"))->Run(); 2977 "};"))->Run();
2979 Local<Value> trouble = global->Get(v8_str("trouble")); 2978 Local<Value> trouble = global->Get(v8_str("trouble"));
2980 CHECK(trouble->IsFunction()); 2979 CHECK(trouble->IsFunction());
2981 Local<Value> trouble_callee = global->Get(v8_str("trouble_callee")); 2980 Local<Value> trouble_callee = global->Get(v8_str("trouble_callee"));
2982 CHECK(trouble_callee->IsFunction()); 2981 CHECK(trouble_callee->IsFunction());
2983 Local<Value> trouble_caller = global->Get(v8_str("trouble_caller")); 2982 Local<Value> trouble_caller = global->Get(v8_str("trouble_caller"));
2984 CHECK(trouble_caller->IsFunction()); 2983 CHECK(trouble_caller->IsFunction());
2985 Function::Cast(*trouble_caller)->Call(global, 0, NULL); 2984 Function::Cast(*trouble_caller)->Call(global, 0, NULL);
2986 CHECK_EQ(1, report_count); 2985 CHECK_EQ(1, report_count);
2987 v8::V8::RemoveMessageListeners(ApiUncaughtExceptionTestListener);
2988 }
2989
2990
2991 TEST(TryCatchFinallyUsingTryCatchHandler) {
2992 v8::HandleScope scope;
2993 LocalContext env;
2994 v8::TryCatch try_catch;
2995 Script::Compile(v8_str("try { throw ''; } catch (e) {}"))->Run();
2996 CHECK(!try_catch.HasCaught());
2997 Script::Compile(v8_str("try { throw ''; } finally {}"))->Run();
2998 CHECK(try_catch.HasCaught());
2999 try_catch.Reset();
3000 Script::Compile(v8_str("(function() {"
3001 "try { throw ''; } finally { return; }"
3002 "})()"))->Run();
3003 CHECK(!try_catch.HasCaught());
3004 Script::Compile(v8_str("(function()"
3005 " { try { throw ''; } finally { throw 0; }"
3006 "})()"))->Run();
3007 CHECK(try_catch.HasCaught());
3008 } 2986 }
3009 2987
3010 2988
3011 // SecurityHandler can't be run twice 2989 // SecurityHandler can't be run twice
3012 TEST(SecurityHandler) { 2990 TEST(SecurityHandler) {
3013 v8::HandleScope scope0; 2991 v8::HandleScope scope0;
3014 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New(); 2992 v8::Handle<v8::ObjectTemplate> global_template = v8::ObjectTemplate::New();
3015 global_template->SetAccessCheckCallbacks(NamedSecurityTestCallback, 2993 global_template->SetAccessCheckCallbacks(NamedSecurityTestCallback,
3016 IndexedSecurityTestCallback); 2994 IndexedSecurityTestCallback);
3017 // Create an environment 2995 // Create an environment
(...skipping 2356 matching lines...) Expand 10 before | Expand all | Expand 10 after
5374 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');"); 5352 CompileRun("for (var j = 0; j < 10; j++) new RegExp('');");
5375 } 5353 }
5376 // Test CallIC. 5354 // Test CallIC.
5377 for (int i = 0; i < 2; i++) { 5355 for (int i = 0; i < 2; i++) {
5378 LocalContext context; 5356 LocalContext context;
5379 context->Global()->Set(v8_str("tmp"), v8::True()); 5357 context->Global()->Set(v8_str("tmp"), v8::True());
5380 context->Global()->Delete(v8_str("tmp")); 5358 context->Global()->Delete(v8_str("tmp"));
5381 CompileRun("for (var j = 0; j < 10; j++) RegExp('')"); 5359 CompileRun("for (var j = 0; j < 10; j++) RegExp('')");
5382 } 5360 }
5383 } 5361 }
OLDNEW
« no previous file with comments | « src/top.cc ('k') | test/message/try-catch-finally-return-in-finally.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698