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

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

Issue 1965823002: Initial isolate reload support (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
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/debugger.h" 6 #include "vm/debugger.h"
7 #include "vm/unit_test.h" 7 #include "vm/unit_test.h"
8 8
9 namespace dart { 9 namespace dart {
10 10
11 #ifndef PRODUCT 11 #ifndef PRODUCT
12 12
13 DECLARE_FLAG(bool, remove_script_timestamps_for_test);
14
13 // Search for the formatted string in buffer. 15 // Search for the formatted string in buffer.
14 // 16 //
15 // TODO(turnidge): This function obscures the line number of failing 17 // TODO(turnidge): This function obscures the line number of failing
16 // EXPECTs. Rework this. 18 // EXPECTs. Rework this.
17 static void ExpectSubstringF(const char* buff, const char* fmt, ...) { 19 static void ExpectSubstringF(const char* buff, const char* fmt, ...) {
18 va_list args; 20 va_list args;
19 va_start(args, fmt); 21 va_start(args, fmt);
20 intptr_t len = OS::VSNPrint(NULL, 0, fmt, args); 22 intptr_t len = OS::VSNPrint(NULL, 0, fmt, args);
21 va_end(args); 23 va_end(args);
22 24
23 char* buffer = Thread::Current()->zone()->Alloc<char>(len + 1); 25 char* buffer = Thread::Current()->zone()->Alloc<char>(len + 1);
24 va_list args2; 26 va_list args2;
25 va_start(args2, fmt); 27 va_start(args2, fmt);
26 OS::VSNPrint(buffer, (len + 1), fmt, args2); 28 OS::VSNPrint(buffer, (len + 1), fmt, args2);
27 va_end(args2); 29 va_end(args2);
28 30
29 EXPECT_SUBSTRING(buffer, buff); 31 EXPECT_SUBSTRING(buffer, buff);
30 } 32 }
31 33
32 34
33 TEST_CASE(Debugger_PrintBreakpointsToJSONArray) { 35 TEST_CASE(Debugger_PrintBreakpointsToJSONArray) {
34 const char* kScriptChars = 36 const char* kScriptChars =
35 "main() {\n" 37 "main() {\n"
36 " var x = new StringBuffer();\n" 38 " var x = new StringBuffer();\n"
37 " x.add('won');\n" 39 " x.add('won');\n"
38 " x.add('too');\n" 40 " x.add('too');\n"
39 " return x.toString();\n" 41 " return x.toString();\n"
40 "}\n"; 42 "}\n";
43 SetFlagScope<bool> sfs(&FLAG_remove_script_timestamps_for_test, true);
41 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); 44 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
42 EXPECT_VALID(lib); 45 EXPECT_VALID(lib);
43 Library& vmlib = Library::Handle(); 46 Library& vmlib = Library::Handle();
44 vmlib ^= Api::UnwrapHandle(lib); 47 vmlib ^= Api::UnwrapHandle(lib);
45 EXPECT(!vmlib.IsNull()); 48 EXPECT(!vmlib.IsNull());
46 49
47 Isolate* isolate = Isolate::Current(); 50 Isolate* isolate = Isolate::Current();
48 Debugger* debugger = isolate->debugger(); 51 Debugger* debugger = isolate->debugger();
49 52
50 // Empty case. 53 // Empty case.
(...skipping 15 matching lines...) Expand all
66 { 69 {
67 JSONArray jsarr(&js); 70 JSONArray jsarr(&js);
68 debugger->PrintBreakpointsToJSONArray(&jsarr); 71 debugger->PrintBreakpointsToJSONArray(&jsarr);
69 } 72 }
70 ExpectSubstringF( 73 ExpectSubstringF(
71 js.ToCString(), 74 js.ToCString(),
72 "[{\"type\":\"Breakpoint\",\"fixedId\":true,\"id\":\"breakpoints\\/2\"," 75 "[{\"type\":\"Breakpoint\",\"fixedId\":true,\"id\":\"breakpoints\\/2\","
73 "\"breakpointNumber\":2,\"resolved\":false," 76 "\"breakpointNumber\":2,\"resolved\":false,"
74 "\"location\":{\"type\":\"UnresolvedSourceLocation\"," 77 "\"location\":{\"type\":\"UnresolvedSourceLocation\","
75 "\"script\":{\"type\":\"@Script\",\"fixedId\":true," 78 "\"script\":{\"type\":\"@Script\",\"fixedId\":true,"
76 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," 79 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\\/0\","
77 "\"uri\":\"test-lib\"," 80 "\"uri\":\"test-lib\","
78 "\"_kind\":\"script\"},\"line\":3}}," 81 "\"_kind\":\"script\"},\"line\":3}},"
79 "{\"type\":\"Breakpoint\",\"fixedId\":true,\"id\":\"breakpoints\\/1\"," 82 "{\"type\":\"Breakpoint\",\"fixedId\":true,\"id\":\"breakpoints\\/1\","
80 "\"breakpointNumber\":1,\"resolved\":false," 83 "\"breakpointNumber\":1,\"resolved\":false,"
81 "\"location\":{\"type\":\"UnresolvedSourceLocation\"," 84 "\"location\":{\"type\":\"UnresolvedSourceLocation\","
82 "\"script\":{\"type\":\"@Script\",\"fixedId\":true," 85 "\"script\":{\"type\":\"@Script\",\"fixedId\":true,"
83 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\"," 86 "\"id\":\"libraries\\/%" Pd "\\/scripts\\/test-lib\\/0\","
84 "\"uri\":\"test-lib\"," 87 "\"uri\":\"test-lib\","
85 "\"_kind\":\"script\"},\"line\":2}}]", 88 "\"_kind\":\"script\"},\"line\":2}}]",
86 vmlib.index(), vmlib.index()); 89 vmlib.index(), vmlib.index());
87 } 90 }
88 } 91 }
89 92
90 93
91 static bool saw_paused_event = false; 94 static bool saw_paused_event = false;
92 95
93 static void InspectPausedEvent(Dart_IsolateId isolate_id, 96 static void InspectPausedEvent(Dart_IsolateId isolate_id,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 EXPECT_VALID(result); 135 EXPECT_VALID(result);
133 EXPECT(Dart_IsString(result)); 136 EXPECT(Dart_IsString(result));
134 137
135 // We ran the code in InspectPausedEvent. 138 // We ran the code in InspectPausedEvent.
136 EXPECT(saw_paused_event); 139 EXPECT(saw_paused_event);
137 } 140 }
138 141
139 #endif // !PRODUCT 142 #endif // !PRODUCT
140 143
141 } // namespace dart 144 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698