Index: runtime/vm/source_report_test.cc |
diff --git a/runtime/vm/source_report_test.cc b/runtime/vm/source_report_test.cc |
index 0e1bb7984ff73eb34eeca1bedbbdbb2f1e4e7d59..b213a20311406ac4ae9ac50ce016d0c6f03ee953 100644 |
--- a/runtime/vm/source_report_test.cc |
+++ b/runtime/vm/source_report_test.cc |
@@ -458,4 +458,49 @@ TEST_CASE(SourceReport_MultipleReports) { |
buffer); |
} |
+ |
+TEST_CASE(SourceReport_PossibleBreakpoints_Simple) { |
+ char buffer[1024]; |
+ const char* kScript = |
+ "helper0() {}\n" |
+ "helper1() {}\n" |
+ "main() {\n" |
+ " if (true) {\n" |
+ " helper0();\n" |
+ " } else {\n" |
+ " helper1();\n" |
+ " }\n" |
+ "}"; |
+ |
+ Library& lib = Library::Handle(); |
+ lib ^= ExecuteScript(kScript); |
+ ASSERT(!lib.IsNull()); |
+ const Script& script = Script::Handle(lib.LookupScript( |
+ String::Handle(String::New("test-lib")))); |
+ |
+ SourceReport report(SourceReport::kPossibleBreakpoints); |
+ JSONStream js; |
+ report.PrintJSON(&js, script); |
+ ElideJSONSubstring("classes", js.ToCString(), buffer); |
+ ElideJSONSubstring("libraries", buffer, buffer); |
+ EXPECT_STREQ( |
+ "{\"type\":\"SourceReport\",\"ranges\":[" |
+ |
+ // helper0. |
+ "{\"scriptIndex\":0,\"startPos\":0,\"endPos\":4,\"compiled\":true," |
+ "\"possibleBreakpoints\":[1,4]}," |
+ |
+ // One range not compiled (helper1). |
+ "{\"scriptIndex\":0,\"startPos\":6,\"endPos\":10,\"compiled\":false}," |
+ |
+ // main. |
+ "{\"scriptIndex\":0,\"startPos\":12,\"endPos\":39,\"compiled\":true," |
+ "\"possibleBreakpoints\":[13,23,32,39]}]," |
+ |
+ // Only one script in the script table. |
+ "\"scripts\":[{\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\"," |
+ "\"uri\":\"test-lib\",\"_kind\":\"script\"}]}", |
+ buffer); |
+} |
+ |
} // namespace dart |