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

Unified Diff: test/cctest/test-debug.cc

Issue 2696163002: [debugger] implement inspector-facing API for code coverage. (Closed)
Patch Set: one more shared export Created 3 years, 10 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 | « src/runtime/runtime-debug.cc ('k') | test/mjsunit/code-coverage-ad-hoc.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-debug.cc
diff --git a/test/cctest/test-debug.cc b/test/cctest/test-debug.cc
index a8eb95084219967a80f02d866fdfc8e93369c959..b30c6d923a0fab7774f36f1fed1b07174eee22e8 100644
--- a/test/cctest/test-debug.cc
+++ b/test/cctest/test-debug.cc
@@ -6624,3 +6624,40 @@ UNINITIALIZED_TEST(DebugSetOutOfMemoryListener) {
}
isolate->Dispose();
}
+
+TEST(DebugCoverage) {
+ i::FLAG_always_opt = false;
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+ v8::debug::Coverage::TogglePrecise(isolate, true);
+ v8::Local<v8::String> source = v8_str(
+ "function f() {\n"
+ "}\n"
+ "f();\n"
+ "f();");
+ CompileRun(source);
+ v8::debug::Coverage coverage = v8::debug::Coverage::Collect(isolate);
+ CHECK_EQ(1u, coverage.ScriptCount());
+ v8::Local<v8::debug::Script> script = coverage.GetScript(0);
+ CHECK(script->Source()
+ .ToLocalChecked()
+ ->Equals(env.local(), source)
+ .FromMaybe(false));
+
+ v8::debug::Coverage::Range range = coverage.GetRange(0);
+ CHECK_EQ(0, range.Start().GetLineNumber());
+ CHECK_EQ(0, range.Start().GetColumnNumber());
+ CHECK_EQ(3, range.End().GetLineNumber());
+ CHECK_EQ(4, range.End().GetColumnNumber());
+ CHECK_EQ(1, range.Count());
+ CHECK_EQ(1u, range.NestedCount());
+
+ range = range.GetNested(0);
+ CHECK_EQ(0, range.Start().GetLineNumber());
+ CHECK_EQ(0, range.Start().GetColumnNumber());
+ CHECK_EQ(1, range.End().GetLineNumber());
+ CHECK_EQ(1, range.End().GetColumnNumber());
+ CHECK_EQ(2, range.Count());
+ CHECK_EQ(0, range.NestedCount());
+}
« no previous file with comments | « src/runtime/runtime-debug.cc ('k') | test/mjsunit/code-coverage-ad-hoc.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698