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

Side by Side Diff: runtime/vm/debugger_test.cc

Issue 2904793002: Allow setting breakpoints in literal function initializers of fields. (Closed)
Patch Set: Address comments on patch set 3. Created 3 years, 6 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 | « runtime/vm/debugger.cc ('k') | runtime/vm/parser.h » ('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 (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
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 static int closure_hit_count = 0;
75 int64_t closure_bp_id[4];
76 static void PausedInClosuresHandler(Dart_IsolateId isolate_id,
77 intptr_t bp_id,
78 const Dart_CodeLocation& location) {
79 EXPECT(bp_id == closure_bp_id[closure_hit_count]);
80 closure_hit_count++;
81 }
82
83 TEST_CASE(Debugger_SetBreakpointInFunctionLiteralFieldInitializers) {
84 const char* kScriptChars =
85 "main() {\n"
86 " var c = new MyClass();\n"
87 " c.closure(1, 2);\n"
88 " MyClass.staticClosure(7, 8);\n"
89 " closure(3, 4);\n"
90 " closureSingleLine(5, 6);\n"
91 "}\n"
92 "class MyClass {\n"
93 " var closure = (int a, int b) {\n"
94 " return a + b;\n"
95 " };\n"
96 " static var staticClosure = (int a, int b) {\n"
97 " return a * b;\n"
98 " };\n"
99 "}\n"
100 "var closure = (int a, int b) {\n"
101 " return a + b;\n"
102 "};\n"
103 "var closureSingleLine = (int a, int b) => a * b;\n"
104 "int v = 10;\n";
105 SetFlagScope<bool> sfs(&FLAG_remove_script_timestamps_for_test, true);
106 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
107 EXPECT_VALID(lib);
108
109 Isolate* isolate = Isolate::Current();
110 Debugger* debugger = isolate->debugger();
111
112 Dart_Handle url = NewString(TestCase::url());
113 Dart_Handle result = Dart_SetBreakpoint(url, 10);
114 EXPECT_VALID(result);
115 EXPECT(Dart_IsInteger(result));
116 EXPECT_VALID(Dart_IntegerToInt64(result, &closure_bp_id[0]));
117
118 result = Dart_SetBreakpoint(url, 13);
119 EXPECT_VALID(result);
120 EXPECT(Dart_IsInteger(result));
121 EXPECT_VALID(Dart_IntegerToInt64(result, &closure_bp_id[1]));
122
123 result = Dart_SetBreakpoint(url, 17);
124 EXPECT_VALID(result);
125 EXPECT(Dart_IsInteger(result));
126 EXPECT_VALID(Dart_IntegerToInt64(result, &closure_bp_id[2]));
127
128 result = Dart_SetBreakpoint(url, 19);
129 EXPECT_VALID(result);
130 EXPECT(Dart_IsInteger(result));
131 EXPECT_VALID(Dart_IntegerToInt64(result, &closure_bp_id[3]));
132
133 result = Dart_SetBreakpoint(url, 20);
134 EXPECT_ERROR(result, "could not set breakpoint at line 20");
135
136 EXPECT(debugger->GetBreakpointById(closure_bp_id[0]) != NULL);
137 EXPECT(debugger->GetBreakpointById(closure_bp_id[1]) != NULL);
138 EXPECT(debugger->GetBreakpointById(closure_bp_id[2]) != NULL);
139 EXPECT(debugger->GetBreakpointById(closure_bp_id[3]) != NULL);
140
141 Dart_SetPausedEventHandler(PausedInClosuresHandler);
142 result = Dart_Invoke(lib, NewString("main"), 0, NULL);
143 EXPECT_VALID(result);
144 // TODO(sivachandra): Understand why a breakpoint on a single line
145 // functional literal is not being hit. When that issue is resolved,
146 // adjust this test to check hitting the breakpoint at line 19 also.
147 EXPECT(closure_hit_count == 3);
148 }
149
74 TEST_CASE(Debugger_RemoveBreakpoint) { 150 TEST_CASE(Debugger_RemoveBreakpoint) {
75 const char* kScriptChars = 151 const char* kScriptChars =
76 "main() {\n" 152 "main() {\n"
77 " var x = new StringBuffer();\n" 153 " var x = new StringBuffer();\n"
78 " x.add('won');\n" 154 " x.add('won');\n"
79 " x.add('too');\n" 155 " x.add('too');\n"
80 " return x.toString();\n" 156 " return x.toString();\n"
81 "}\n"; 157 "}\n";
82 SetFlagScope<bool> sfs(&FLAG_remove_script_timestamps_for_test, true); 158 SetFlagScope<bool> sfs(&FLAG_remove_script_timestamps_for_test, true);
83 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 159 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 "enter(bar1) enter(bar2) enter(bar3) enter(foo) " 580 "enter(bar1) enter(bar2) enter(bar3) enter(foo) "
505 "enter(bar3) enter(foo) " 581 "enter(bar3) enter(foo) "
506 "exit(foo) exit(bar3) exit(bar2) exit(bar1) ", 582 "exit(foo) exit(bar3) exit(bar2) exit(bar1) ",
507 result_cstr); 583 result_cstr);
508 EXPECT(saw_paused_event); 584 EXPECT(saw_paused_event);
509 } 585 }
510 586
511 #endif // !PRODUCT 587 #endif // !PRODUCT
512 588
513 } // namespace dart 589 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698