OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 #include "vm/debugger.h" |
| 6 #include "vm/unit_test.h" |
| 7 |
| 8 namespace dart { |
| 9 |
| 10 TEST_CASE(Debugger_PrintBreakpointsToJSONArray) { |
| 11 const char* kScriptChars = |
| 12 "void main() {\n" |
| 13 " print('won');\n" |
| 14 " print('too');\n" |
| 15 " print('free');\n" |
| 16 " print('for');\n" |
| 17 "}\n"; |
| 18 Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL); |
| 19 EXPECT_VALID(lib); |
| 20 |
| 21 Isolate* isolate = Isolate::Current(); |
| 22 Debugger* debugger = isolate->debugger(); |
| 23 const String& url = String::Handle(String::New(TestCase::url())); |
| 24 |
| 25 // Empty case. |
| 26 { |
| 27 JSONStream js; |
| 28 { |
| 29 JSONArray jsarr(&js); |
| 30 debugger->PrintBreakpointsToJSONArray(&jsarr); |
| 31 } |
| 32 EXPECT_STREQ("[]", js.ToCString()); |
| 33 } |
| 34 |
| 35 // Test with a couple of breakpoints. |
| 36 debugger->SetBreakpointAtLine(url, 2); |
| 37 debugger->SetBreakpointAtLine(url, 3); |
| 38 { |
| 39 JSONStream js; |
| 40 { |
| 41 JSONArray jsarr(&js); |
| 42 debugger->PrintBreakpointsToJSONArray(&jsarr); |
| 43 } |
| 44 EXPECT_STREQ( |
| 45 "[{\"type\":\"Breakpoint\",\"id\":2," |
| 46 "\"enabled\":true,\"resolved\":false," |
| 47 "\"location\":{\"type\":\"Location\",\"libId\":12," |
| 48 "\"script\":\"dart:test-lib\",\"tokenPos\":12}}," |
| 49 "{\"type\":\"Breakpoint\",\"id\":1," |
| 50 "\"enabled\":true,\"resolved\":false," |
| 51 "\"location\":{\"type\":\"Location\",\"libId\":12," |
| 52 "\"script\":\"dart:test-lib\",\"tokenPos\":6}}]", |
| 53 js.ToCString()); |
| 54 } |
| 55 } |
| 56 |
| 57 } // namespace dart |
OLD | NEW |