Chromium Code Reviews| 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 3440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3451 DebugLocalContext env; | 3451 DebugLocalContext env; |
| 3452 v8::Isolate* isolate = env->GetIsolate(); | 3452 v8::Isolate* isolate = env->GetIsolate(); |
| 3453 v8::HandleScope scope(isolate); | 3453 v8::HandleScope scope(isolate); |
| 3454 | 3454 |
| 3455 // Register a debug event listener which steps and counts. | 3455 // Register a debug event listener which steps and counts. |
| 3456 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); | 3456 v8::Debug::SetDebugEventListener(isolate, DebugEventStep); |
| 3457 | 3457 |
| 3458 v8::Local<v8::Context> context = env.context(); | 3458 v8::Local<v8::Context> context = env.context(); |
| 3459 // Create a function for testing stepping. Run it to allow it to get | 3459 // Create a function for testing stepping. Run it to allow it to get |
| 3460 // optimized. | 3460 // optimized. |
| 3461 const char* src = "function foo(x) { " | 3461 const char* src = |
| 3462 " var a;" | 3462 "function foo(x) { " |
| 3463 " a = x ? 1 : 2;" | 3463 " return x ? 1 : 2;" |
|
vogelheim
2016/03/15 09:51:51
Hmm. Not sure, but this might count as cheating...
Yang
2016/03/15 10:00:12
The old version tested both a conditional, and the
| |
| 3464 " return a;" | 3464 "}" |
| 3465 "}" | 3465 "foo()"; |
| 3466 "foo()"; | |
| 3467 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); | 3466 v8::Local<v8::Function> foo = CompileFunction(&env, src, "foo"); |
| 3468 SetBreakPoint(foo, 0); // "var a;" | 3467 SetBreakPoint(foo, 0); // "var a;" |
| 3469 | 3468 |
| 3470 step_action = StepIn; | 3469 step_action = StepIn; |
| 3471 break_point_hit_count = 0; | 3470 break_point_hit_count = 0; |
| 3472 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); | 3471 foo->Call(context, env->Global(), 0, NULL).ToLocalChecked(); |
| 3473 CHECK_EQ(3, break_point_hit_count); | 3472 CHECK_EQ(2, break_point_hit_count); |
| 3474 | 3473 |
| 3475 step_action = StepIn; | 3474 step_action = StepIn; |
| 3476 break_point_hit_count = 0; | 3475 break_point_hit_count = 0; |
| 3477 const int argc = 1; | 3476 const int argc = 1; |
| 3478 v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)}; | 3477 v8::Local<v8::Value> argv_true[argc] = {v8::True(isolate)}; |
| 3479 foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked(); | 3478 foo->Call(context, env->Global(), argc, argv_true).ToLocalChecked(); |
| 3480 CHECK_EQ(3, break_point_hit_count); | 3479 CHECK_EQ(2, break_point_hit_count); |
| 3481 | 3480 |
| 3482 // Get rid of the debug event listener. | 3481 // Get rid of the debug event listener. |
| 3483 v8::Debug::SetDebugEventListener(isolate, nullptr); | 3482 v8::Debug::SetDebugEventListener(isolate, nullptr); |
| 3484 CheckDebuggerUnloaded(isolate); | 3483 CheckDebuggerUnloaded(isolate); |
| 3485 } | 3484 } |
| 3486 | 3485 |
| 3487 | 3486 |
| 3488 TEST(StepInOutSimple) { | 3487 TEST(StepInOutSimple) { |
| 3489 DebugLocalContext env; | 3488 DebugLocalContext env; |
| 3490 v8::HandleScope scope(env->GetIsolate()); | 3489 v8::HandleScope scope(env->GetIsolate()); |
| (...skipping 4573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8064 CHECK_EQ(22, iterator->GetBreakLocation().position()); | 8063 CHECK_EQ(22, iterator->GetBreakLocation().position()); |
| 8065 iterator->Next(); | 8064 iterator->Next(); |
| 8066 CHECK(iterator->GetBreakLocation().IsReturn()); | 8065 CHECK(iterator->GetBreakLocation().IsReturn()); |
| 8067 CHECK_EQ(50, iterator->GetBreakLocation().position()); | 8066 CHECK_EQ(50, iterator->GetBreakLocation().position()); |
| 8068 iterator->Next(); | 8067 iterator->Next(); |
| 8069 CHECK(iterator->Done()); | 8068 CHECK(iterator->Done()); |
| 8070 delete iterator; | 8069 delete iterator; |
| 8071 | 8070 |
| 8072 DisableDebugger(isolate); | 8071 DisableDebugger(isolate); |
| 8073 } | 8072 } |
| OLD | NEW |