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

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

Issue 24508006: remove uses of static oddball accessors using GetCurrent in advance of removal from api (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: nits Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-decls.cc » ('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 2382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2393 ClearBreakPoint(bp); 2393 ClearBreakPoint(bp);
2394 v8::Debug::SetDebugEventListener2(NULL); 2394 v8::Debug::SetDebugEventListener2(NULL);
2395 CheckDebuggerUnloaded(); 2395 CheckDebuggerUnloaded();
2396 } 2396 }
2397 2397
2398 2398
2399 // Test that the evaluation of expressions when a break point is hit generates 2399 // Test that the evaluation of expressions when a break point is hit generates
2400 // the correct results. 2400 // the correct results.
2401 TEST(DebugEvaluate) { 2401 TEST(DebugEvaluate) {
2402 DebugLocalContext env; 2402 DebugLocalContext env;
2403 v8::HandleScope scope(env->GetIsolate()); 2403 v8::Isolate* isolate = env->GetIsolate();
2404 v8::HandleScope scope(isolate);
2404 env.ExposeDebug(); 2405 env.ExposeDebug();
2405 2406
2406 // Create a function for checking the evaluation when hitting a break point. 2407 // Create a function for checking the evaluation when hitting a break point.
2407 evaluate_check_function = CompileFunction(&env, 2408 evaluate_check_function = CompileFunction(&env,
2408 evaluate_check_source, 2409 evaluate_check_source,
2409 "evaluate_check"); 2410 "evaluate_check");
2410 // Register the debug event listener 2411 // Register the debug event listener
2411 v8::Debug::SetDebugEventListener2(DebugEventEvaluate); 2412 v8::Debug::SetDebugEventListener2(DebugEventEvaluate);
2412 2413
2413 // Different expected vaules of x and a when in a break point (u = undefined, 2414 // Different expected vaules of x and a when in a break point (u = undefined,
2414 // d = Hello, world!). 2415 // d = Hello, world!).
2415 struct EvaluateCheck checks_uu[] = { 2416 struct EvaluateCheck checks_uu[] = {
2416 {"x", v8::Undefined()}, 2417 {"x", v8::Undefined(isolate)},
2417 {"a", v8::Undefined()}, 2418 {"a", v8::Undefined(isolate)},
2418 {NULL, v8::Handle<v8::Value>()} 2419 {NULL, v8::Handle<v8::Value>()}
2419 }; 2420 };
2420 struct EvaluateCheck checks_hu[] = { 2421 struct EvaluateCheck checks_hu[] = {
2421 {"x", v8::String::New("Hello, world!")}, 2422 {"x", v8::String::New("Hello, world!")},
2422 {"a", v8::Undefined()}, 2423 {"a", v8::Undefined(isolate)},
2423 {NULL, v8::Handle<v8::Value>()} 2424 {NULL, v8::Handle<v8::Value>()}
2424 }; 2425 };
2425 struct EvaluateCheck checks_hh[] = { 2426 struct EvaluateCheck checks_hh[] = {
2426 {"x", v8::String::New("Hello, world!")}, 2427 {"x", v8::String::New("Hello, world!")},
2427 {"a", v8::String::New("Hello, world!")}, 2428 {"a", v8::String::New("Hello, world!")},
2428 {NULL, v8::Handle<v8::Value>()} 2429 {NULL, v8::Handle<v8::Value>()}
2429 }; 2430 };
2430 2431
2431 // Simple test function. The "y=0" is in the function foo to provide a break 2432 // Simple test function. The "y=0" is in the function foo to provide a break
2432 // location. For "y=0" the "y" is at position 15 in the barbar function 2433 // location. For "y=0" the "y" is at position 15 in the barbar function
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2478 " barbar();" 2479 " barbar();"
2479 " y=0;a=x;" 2480 " y=0;a=x;"
2480 "}", 2481 "}",
2481 "bar"); 2482 "bar");
2482 const int barbar_break_position = 8; 2483 const int barbar_break_position = 8;
2483 2484
2484 // Call bar setting breakpoint before a=x in barbar and undefined as 2485 // Call bar setting breakpoint before a=x in barbar and undefined as
2485 // parameter. 2486 // parameter.
2486 checks = checks_uu; 2487 checks = checks_uu;
2487 v8::Handle<v8::Value> argv_bar_1[2] = { 2488 v8::Handle<v8::Value> argv_bar_1[2] = {
2488 v8::Undefined(), 2489 v8::Undefined(isolate),
2489 v8::Number::New(barbar_break_position) 2490 v8::Number::New(barbar_break_position)
2490 }; 2491 };
2491 bar->Call(env->Global(), 2, argv_bar_1); 2492 bar->Call(env->Global(), 2, argv_bar_1);
2492 2493
2493 // Call bar setting breakpoint before a=x in barbar and parameter 2494 // Call bar setting breakpoint before a=x in barbar and parameter
2494 // "Hello, world!". 2495 // "Hello, world!".
2495 checks = checks_hu; 2496 checks = checks_hu;
2496 v8::Handle<v8::Value> argv_bar_2[2] = { 2497 v8::Handle<v8::Value> argv_bar_2[2] = {
2497 v8::String::New("Hello, world!"), 2498 v8::String::New("Hello, world!"),
2498 v8::Number::New(barbar_break_position) 2499 v8::Number::New(barbar_break_position)
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
3098 CHECK_EQ(6, break_point_hit_count); 3099 CHECK_EQ(6, break_point_hit_count);
3099 3100
3100 // Get rid of the debug event listener. 3101 // Get rid of the debug event listener.
3101 v8::Debug::SetDebugEventListener2(NULL); 3102 v8::Debug::SetDebugEventListener2(NULL);
3102 CheckDebuggerUnloaded(); 3103 CheckDebuggerUnloaded();
3103 } 3104 }
3104 3105
3105 3106
3106 TEST(DebugStepIf) { 3107 TEST(DebugStepIf) {
3107 DebugLocalContext env; 3108 DebugLocalContext env;
3108 v8::HandleScope scope(env->GetIsolate()); 3109 v8::Isolate* isolate = env->GetIsolate();
3110 v8::HandleScope scope(isolate);
3109 3111
3110 // Register a debug event listener which steps and counts. 3112 // Register a debug event listener which steps and counts.
3111 v8::Debug::SetDebugEventListener2(DebugEventStep); 3113 v8::Debug::SetDebugEventListener2(DebugEventStep);
3112 3114
3113 // Create a function for testing stepping. Run it to allow it to get 3115 // Create a function for testing stepping. Run it to allow it to get
3114 // optimized. 3116 // optimized.
3115 const int argc = 1; 3117 const int argc = 1;
3116 const char* src = "function foo(x) { " 3118 const char* src = "function foo(x) { "
3117 " a = 1;" 3119 " a = 1;"
3118 " if (x) {" 3120 " if (x) {"
3119 " b = 1;" 3121 " b = 1;"
3120 " } else {" 3122 " } else {"
3121 " c = 1;" 3123 " c = 1;"
3122 " d = 1;" 3124 " d = 1;"
3123 " }" 3125 " }"
3124 "}" 3126 "}"
3125 "a=0; b=0; c=0; d=0; foo()"; 3127 "a=0; b=0; c=0; d=0; foo()";
3126 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3128 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3127 SetBreakPoint(foo, 0); 3129 SetBreakPoint(foo, 0);
3128 3130
3129 // Stepping through the true part. 3131 // Stepping through the true part.
3130 step_action = StepIn; 3132 step_action = StepIn;
3131 break_point_hit_count = 0; 3133 break_point_hit_count = 0;
3132 v8::Handle<v8::Value> argv_true[argc] = { v8::True() }; 3134 v8::Handle<v8::Value> argv_true[argc] = { v8::True(isolate) };
3133 foo->Call(env->Global(), argc, argv_true); 3135 foo->Call(env->Global(), argc, argv_true);
3134 CHECK_EQ(4, break_point_hit_count); 3136 CHECK_EQ(4, break_point_hit_count);
3135 3137
3136 // Stepping through the false part. 3138 // Stepping through the false part.
3137 step_action = StepIn; 3139 step_action = StepIn;
3138 break_point_hit_count = 0; 3140 break_point_hit_count = 0;
3139 v8::Handle<v8::Value> argv_false[argc] = { v8::False() }; 3141 v8::Handle<v8::Value> argv_false[argc] = { v8::False(isolate) };
3140 foo->Call(env->Global(), argc, argv_false); 3142 foo->Call(env->Global(), argc, argv_false);
3141 CHECK_EQ(5, break_point_hit_count); 3143 CHECK_EQ(5, break_point_hit_count);
3142 3144
3143 // Get rid of the debug event listener. 3145 // Get rid of the debug event listener.
3144 v8::Debug::SetDebugEventListener2(NULL); 3146 v8::Debug::SetDebugEventListener2(NULL);
3145 CheckDebuggerUnloaded(); 3147 CheckDebuggerUnloaded();
3146 } 3148 }
3147 3149
3148 3150
3149 TEST(DebugStepSwitch) { 3151 TEST(DebugStepSwitch) {
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
3500 CHECK_EQ(4, break_point_hit_count); 3502 CHECK_EQ(4, break_point_hit_count);
3501 3503
3502 // Get rid of the debug event listener. 3504 // Get rid of the debug event listener.
3503 v8::Debug::SetDebugEventListener2(NULL); 3505 v8::Debug::SetDebugEventListener2(NULL);
3504 CheckDebuggerUnloaded(); 3506 CheckDebuggerUnloaded();
3505 } 3507 }
3506 3508
3507 3509
3508 TEST(DebugConditional) { 3510 TEST(DebugConditional) {
3509 DebugLocalContext env; 3511 DebugLocalContext env;
3510 v8::HandleScope scope(env->GetIsolate()); 3512 v8::Isolate* isolate = env->GetIsolate();
3513 v8::HandleScope scope(isolate);
3511 3514
3512 // Register a debug event listener which steps and counts. 3515 // Register a debug event listener which steps and counts.
3513 v8::Debug::SetDebugEventListener2(DebugEventStep); 3516 v8::Debug::SetDebugEventListener2(DebugEventStep);
3514 3517
3515 // Create a function for testing stepping. Run it to allow it to get 3518 // Create a function for testing stepping. Run it to allow it to get
3516 // optimized. 3519 // optimized.
3517 const char* src = "function foo(x) { " 3520 const char* src = "function foo(x) { "
3518 " var a;" 3521 " var a;"
3519 " a = x ? 1 : 2;" 3522 " a = x ? 1 : 2;"
3520 " return a;" 3523 " return a;"
3521 "}" 3524 "}"
3522 "foo()"; 3525 "foo()";
3523 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); 3526 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo");
3524 SetBreakPoint(foo, 0); // "var a;" 3527 SetBreakPoint(foo, 0); // "var a;"
3525 3528
3526 step_action = StepIn; 3529 step_action = StepIn;
3527 break_point_hit_count = 0; 3530 break_point_hit_count = 0;
3528 foo->Call(env->Global(), 0, NULL); 3531 foo->Call(env->Global(), 0, NULL);
3529 CHECK_EQ(5, break_point_hit_count); 3532 CHECK_EQ(5, break_point_hit_count);
3530 3533
3531 step_action = StepIn; 3534 step_action = StepIn;
3532 break_point_hit_count = 0; 3535 break_point_hit_count = 0;
3533 const int argc = 1; 3536 const int argc = 1;
3534 v8::Handle<v8::Value> argv_true[argc] = { v8::True() }; 3537 v8::Handle<v8::Value> argv_true[argc] = { v8::True(isolate) };
3535 foo->Call(env->Global(), argc, argv_true); 3538 foo->Call(env->Global(), argc, argv_true);
3536 CHECK_EQ(5, break_point_hit_count); 3539 CHECK_EQ(5, break_point_hit_count);
3537 3540
3538 // Get rid of the debug event listener. 3541 // Get rid of the debug event listener.
3539 v8::Debug::SetDebugEventListener2(NULL); 3542 v8::Debug::SetDebugEventListener2(NULL);
3540 CheckDebuggerUnloaded(); 3543 CheckDebuggerUnloaded();
3541 } 3544 }
3542 3545
3543 3546
3544 TEST(StepInOutSimple) { 3547 TEST(StepInOutSimple) {
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
3752 CHECK_EQ(1, break_point_hit_count); 3755 CHECK_EQ(1, break_point_hit_count);
3753 3756
3754 v8::Debug::SetDebugEventListener2(NULL); 3757 v8::Debug::SetDebugEventListener2(NULL);
3755 CheckDebuggerUnloaded(); 3758 CheckDebuggerUnloaded();
3756 } 3759 }
3757 3760
3758 3761
3759 // Test that step in works with function.call. 3762 // Test that step in works with function.call.
3760 TEST(DebugStepFunctionCall) { 3763 TEST(DebugStepFunctionCall) {
3761 DebugLocalContext env; 3764 DebugLocalContext env;
3762 v8::HandleScope scope(env->GetIsolate()); 3765 v8::Isolate* isolate = env->GetIsolate();
3766 v8::HandleScope scope(isolate);
3763 3767
3764 // Create a function for testing stepping. 3768 // Create a function for testing stepping.
3765 v8::Local<v8::Function> foo = CompileFunction( 3769 v8::Local<v8::Function> foo = CompileFunction(
3766 &env, 3770 &env,
3767 "function bar(x, y, z) { if (x == 1) { a = y; b = z; } }" 3771 "function bar(x, y, z) { if (x == 1) { a = y; b = z; } }"
3768 "function foo(a){ debugger;" 3772 "function foo(a){ debugger;"
3769 " if (a) {" 3773 " if (a) {"
3770 " bar.call(this, 1, 2, 3);" 3774 " bar.call(this, 1, 2, 3);"
3771 " } else {" 3775 " } else {"
3772 " bar.call(this, 0);" 3776 " bar.call(this, 0);"
3773 " }" 3777 " }"
3774 "}", 3778 "}",
3775 "foo"); 3779 "foo");
3776 3780
3777 // Register a debug event listener which steps and counts. 3781 // Register a debug event listener which steps and counts.
3778 v8::Debug::SetDebugEventListener2(DebugEventStep); 3782 v8::Debug::SetDebugEventListener2(DebugEventStep);
3779 step_action = StepIn; 3783 step_action = StepIn;
3780 3784
3781 // Check stepping where the if condition in bar is false. 3785 // Check stepping where the if condition in bar is false.
3782 break_point_hit_count = 0; 3786 break_point_hit_count = 0;
3783 foo->Call(env->Global(), 0, NULL); 3787 foo->Call(env->Global(), 0, NULL);
3784 CHECK_EQ(6, break_point_hit_count); 3788 CHECK_EQ(6, break_point_hit_count);
3785 3789
3786 // Check stepping where the if condition in bar is true. 3790 // Check stepping where the if condition in bar is true.
3787 break_point_hit_count = 0; 3791 break_point_hit_count = 0;
3788 const int argc = 1; 3792 const int argc = 1;
3789 v8::Handle<v8::Value> argv[argc] = { v8::True() }; 3793 v8::Handle<v8::Value> argv[argc] = { v8::True(isolate) };
3790 foo->Call(env->Global(), argc, argv); 3794 foo->Call(env->Global(), argc, argv);
3791 CHECK_EQ(8, break_point_hit_count); 3795 CHECK_EQ(8, break_point_hit_count);
3792 3796
3793 v8::Debug::SetDebugEventListener2(NULL); 3797 v8::Debug::SetDebugEventListener2(NULL);
3794 CheckDebuggerUnloaded(); 3798 CheckDebuggerUnloaded();
3795 3799
3796 // Register a debug event listener which just counts. 3800 // Register a debug event listener which just counts.
3797 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount); 3801 v8::Debug::SetDebugEventListener2(DebugEventBreakPointHitCount);
3798 3802
3799 break_point_hit_count = 0; 3803 break_point_hit_count = 0;
(...skipping 3753 matching lines...) Expand 10 before | Expand all | Expand 10 after
7553 TEST(LiveEditDisabled) { 7557 TEST(LiveEditDisabled) {
7554 v8::internal::FLAG_allow_natives_syntax = true; 7558 v8::internal::FLAG_allow_natives_syntax = true;
7555 LocalContext env; 7559 LocalContext env;
7556 v8::HandleScope scope(env->GetIsolate()); 7560 v8::HandleScope scope(env->GetIsolate());
7557 v8::Debug::SetLiveEditEnabled(false), env->GetIsolate(); 7561 v8::Debug::SetLiveEditEnabled(false), env->GetIsolate();
7558 CompileRun("%LiveEditCompareStrings('', '')"); 7562 CompileRun("%LiveEditCompareStrings('', '')");
7559 } 7563 }
7560 7564
7561 7565
7562 #endif // ENABLE_DEBUGGER_SUPPORT 7566 #endif // ENABLE_DEBUGGER_SUPPORT
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/cctest/test-decls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698