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

Unified Diff: runtime/vm/source_report_test.cc

Issue 1566793002: Expose the new _getSourceReport api in the service protocol. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code rev Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/source_report.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/source_report_test.cc
diff --git a/runtime/vm/source_report_test.cc b/runtime/vm/source_report_test.cc
index 075ac36d472354e93440dc0b2abc13d1ba0dfbac..0e1bb7984ff73eb34eeca1bedbbdbb2f1e4e7d59 100644
--- a/runtime/vm/source_report_test.cc
+++ b/runtime/vm/source_report_test.cc
@@ -409,4 +409,53 @@ TEST_CASE(SourceReport_CallSites_PolymorphicCall) {
buffer);
}
+
+TEST_CASE(SourceReport_MultipleReports) {
+ char buffer[1024];
+ const char* kScript =
+ "helper0() {}\n"
+ "helper1() {}\n"
+ "main() {\n"
+ " helper0();\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::kCallSites|SourceReport::kCoverage);
+ JSONStream js;
+ report.PrintJSON(&js, script);
+ ElideJSONSubstring("classes", js.ToCString(), buffer);
+ ElideJSONSubstring("libraries", buffer, buffer);
+ EXPECT_STREQ(
+ "{\"type\":\"SourceReport\",\"ranges\":["
+
+ // One range compiled with no callsites (helper0).
+ "{\"scriptIndex\":0,\"startPos\":0,\"endPos\":4,\"compiled\":true,"
+ "\"callSites\":[],"
+ "\"coverage\":{\"hits\":[],\"misses\":[]}},"
+
+ // One range not compiled (helper1).
+ "{\"scriptIndex\":0,\"startPos\":6,\"endPos\":10,\"compiled\":false},"
+
+ // One range compiled with one callsite (main).
+ "{\"scriptIndex\":0,\"startPos\":12,\"endPos\":22,\"compiled\":true,"
+ "\"callSites\":["
+ "{\"name\":\"helper0\",\"tokenPos\":17,\"cacheEntries\":["
+ "{\"target\":{\"type\":\"@Function\",\"fixedId\":true,\"id\":\"\","
+ "\"name\":\"helper0\",\"owner\":{\"type\":\"@Library\",\"fixedId\":true,"
+ "\"id\":\"\",\"name\":\"\",\"uri\":\"test-lib\"},"
+ "\"_kind\":\"RegularFunction\",\"static\":true,\"const\":false,"
+ "\"_intrinsic\":false,\"_native\":false},\"count\":1}]}],"
+ "\"coverage\":{\"hits\":[17],\"misses\":[]}}],"
+
+ // One script in the script table.
+ "\"scripts\":[{\"type\":\"@Script\",\"fixedId\":true,\"id\":\"\","
+ "\"uri\":\"test-lib\",\"_kind\":\"script\"}]}",
+ buffer);
+}
+
} // namespace dart
« no previous file with comments | « runtime/vm/source_report.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698