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

Unified Diff: test/mjsunit/code-coverage-precise.js

Issue 2700743002: [inspector] extend protocol for code coverage. (Closed)
Patch Set: fix 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 | « test/mjsunit/code-coverage-ad-hoc.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/code-coverage-precise.js
diff --git a/test/mjsunit/code-coverage-precise.js b/test/mjsunit/code-coverage-precise.js
index a25542dae968c6803fa78682fb19c9a3d6ff2805..03015f920268a3fde60eea7052ca54f46c2cabba 100644
--- a/test/mjsunit/code-coverage-precise.js
+++ b/test/mjsunit/code-coverage-precise.js
@@ -8,39 +8,21 @@
function GetCoverage(source) {
for (var script of %DebugCollectCoverage()) {
- if (script.script.source == source) return script.toplevel;
+ if (script.script.source == source) return script;
}
return undefined;
}
-function ApplyCoverageToSource(source, range) {
- var content = "";
- var cursor = range.start;
- if (range.inner) for (var inner of range.inner) {
- content += source.substring(cursor, inner.start);
- content += ApplyCoverageToSource(source, inner);
- cursor = inner.end;
- }
- content += source.substring(cursor, range.end);
- return `[${content}](${range.name}:${range.count})`;
-}
-
function TestCoverage(name, source, expectation) {
source = source.trim();
eval(source);
- %CollectGarbage("remove dead objects");
+ %CollectGarbage("collect dead objects");
var coverage = GetCoverage(source);
- if (expectation === undefined) {
- assertEquals(undefined, coverage);
- } else {
- expectation = expectation.trim();
- var result = ApplyCoverageToSource(source, coverage);
- print(result);
- assertEquals(expectation, result, name + " failed");
- }
+ var result = JSON.stringify(coverage);
+ print(result);
+ assertEquals(JSON.stringify(expectation), result, name + " failed");
}
-
// Without precise coverage enabled, we lose coverage data to the GC.
TestCoverage(
"call an IIFE",
@@ -69,9 +51,7 @@ TestCoverage(
`
(function f() {})();
`,
-`
-[([function f() {}](f:1))();](:1)
-`
+[{"start":0,"end":20,"count":1},{"start":1,"end":16,"count":1}]
);
TestCoverage(
@@ -82,12 +62,7 @@ for (var i = 0; i < 10; i++) {
i += f();
}
`,
-`
-[for (var i = 0; i < 10; i++) {
- let f = [() => 1](f:5);
- i += f();
-}](:1)
-`
+[{"start":0,"end":63,"count":1},{"start":41,"end":48,"count":5}]
);
%DebugTogglePreciseCoverage(false);
« no previous file with comments | « test/mjsunit/code-coverage-ad-hoc.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698