Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/dart_api_impl.h" | 5 #include "vm/dart_api_impl.h" |
| 6 #include "vm/dart_api_message.h" | 6 #include "vm/dart_api_message.h" |
| 7 #include "vm/debugger.h" | 7 #include "vm/debugger.h" |
| 8 #include "vm/message.h" | 8 #include "vm/message.h" |
| 9 #include "vm/unit_test.h" | 9 #include "vm/unit_test.h" |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 result = Dart_SetBreakpoint(NewString("not_yet_loaded_script_uri"), 4); | 64 result = Dart_SetBreakpoint(NewString("not_yet_loaded_script_uri"), 4); |
| 65 EXPECT_VALID(result); | 65 EXPECT_VALID(result); |
| 66 EXPECT(Dart_IsInteger(result)); | 66 EXPECT(Dart_IsInteger(result)); |
| 67 int64_t bp_id2 = 0; | 67 int64_t bp_id2 = 0; |
| 68 EXPECT_VALID(Dart_IntegerToInt64(result, &bp_id2)); | 68 EXPECT_VALID(Dart_IntegerToInt64(result, &bp_id2)); |
| 69 | 69 |
| 70 EXPECT(debugger->GetBreakpointById(bp_id1) != NULL); | 70 EXPECT(debugger->GetBreakpointById(bp_id1) != NULL); |
| 71 EXPECT(debugger->GetBreakpointById(bp_id2) != NULL); | 71 EXPECT(debugger->GetBreakpointById(bp_id2) != NULL); |
| 72 } | 72 } |
| 73 | 73 |
| 74 TEST_CASE(Debugger_SetBreakpointInFunctionLiteralFieldInitializers) { | |
| 75 const char* kScriptChars = | |
| 76 "main() {\n" | |
| 77 " var c = new MyClass();\n" | |
| 78 " c.closure(1, 2);\n" | |
| 79 " closure(3, 4);\n" | |
| 80 "}\n" | |
| 81 "class MyClass {\n" | |
| 82 " var closure = (int a, int b) {\n" | |
| 83 " return a + b;\n" | |
| 84 " };\n" | |
| 85 "}\n" | |
| 86 "var closure = (int a, int b) {\n" | |
| 87 " return a + b;\n" | |
| 88 "};\n"; | |
|
siva
2017/05/24 19:51:23
Can we add more tests
1. => function tests e.g var
sivachandra
2017/05/26 07:17:58
Done.
| |
| 89 SetFlagScope<bool> sfs(&FLAG_remove_script_timestamps_for_test, true); | |
| 90 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | |
| 91 EXPECT_VALID(lib); | |
| 92 | |
| 93 Isolate* isolate = Isolate::Current(); | |
| 94 Debugger* debugger = isolate->debugger(); | |
| 95 | |
| 96 Dart_Handle url = NewString(TestCase::url()); | |
| 97 Dart_Handle result = Dart_SetBreakpoint(url, 8); | |
| 98 EXPECT_VALID(result); | |
| 99 EXPECT(Dart_IsInteger(result)); | |
| 100 int64_t bp_id1 = 0; | |
| 101 EXPECT_VALID(Dart_IntegerToInt64(result, &bp_id1)); | |
| 102 | |
| 103 result = Dart_SetBreakpoint(url, 12); | |
| 104 EXPECT_VALID(result); | |
| 105 EXPECT(Dart_IsInteger(result)); | |
| 106 int64_t bp_id2 = 0; | |
| 107 EXPECT_VALID(Dart_IntegerToInt64(result, &bp_id2)); | |
| 108 | |
| 109 EXPECT(debugger->GetBreakpointById(bp_id1) != NULL); | |
| 110 EXPECT(debugger->GetBreakpointById(bp_id2) != NULL); | |
|
siva
2017/05/24 19:51:23
Should test if the breakpoint is actually hit by r
sivachandra
2017/05/26 07:17:58
Done.
| |
| 111 } | |
| 112 | |
| 74 TEST_CASE(Debugger_RemoveBreakpoint) { | 113 TEST_CASE(Debugger_RemoveBreakpoint) { |
| 75 const char* kScriptChars = | 114 const char* kScriptChars = |
| 76 "main() {\n" | 115 "main() {\n" |
| 77 " var x = new StringBuffer();\n" | 116 " var x = new StringBuffer();\n" |
| 78 " x.add('won');\n" | 117 " x.add('won');\n" |
| 79 " x.add('too');\n" | 118 " x.add('too');\n" |
| 80 " return x.toString();\n" | 119 " return x.toString();\n" |
| 81 "}\n"; | 120 "}\n"; |
| 82 SetFlagScope<bool> sfs(&FLAG_remove_script_timestamps_for_test, true); | 121 SetFlagScope<bool> sfs(&FLAG_remove_script_timestamps_for_test, true); |
| 83 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); | 122 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 "enter(bar1) enter(bar2) enter(bar3) enter(foo) " | 543 "enter(bar1) enter(bar2) enter(bar3) enter(foo) " |
| 505 "enter(bar3) enter(foo) " | 544 "enter(bar3) enter(foo) " |
| 506 "exit(foo) exit(bar3) exit(bar2) exit(bar1) ", | 545 "exit(foo) exit(bar3) exit(bar2) exit(bar1) ", |
| 507 result_cstr); | 546 result_cstr); |
| 508 EXPECT(saw_paused_event); | 547 EXPECT(saw_paused_event); |
| 509 } | 548 } |
| 510 | 549 |
| 511 #endif // !PRODUCT | 550 #endif // !PRODUCT |
| 512 | 551 |
| 513 } // namespace dart | 552 } // namespace dart |
| OLD | NEW |