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

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

Issue 2694623003: [debugger] change coverage format to nested, with function name. (Closed)
Patch Set: address comments 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 394291e1c54779062bf678770f3884fd2c2d6385..344e2f5397d3154ba5b8ccb33e3e493ba3706f55 100644
--- a/test/mjsunit/code-coverage-precise.js
+++ b/test/mjsunit/code-coverage-precise.js
@@ -7,32 +7,28 @@
// Test precise code coverage.
function GetCoverage(source) {
- var scripts = %DebugGetLoadedScripts();
- for (var script of scripts) {
- if (script.source == source) {
- var coverage = %DebugCollectCoverage();
- for (var data of coverage) {
- if (data.script_id == script.id) return data.entries;
- }
- }
+ for (var script of %DebugCollectCoverage()) {
+ if (script.script.source == source) return script.toplevel;
}
return undefined;
}
-function ApplyCoverageToSource(source, coverage) {
- var result = "";
- var cursor = 0;
- for (var entry of coverage) {
- var chunk = source.substring(cursor, entry.end_position);
- cursor = entry.end_position;
- result += `[${chunk}[${entry.count}]]`;
+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;
}
- return result;
+ 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");
var coverage = GetCoverage(source);
if (expectation === undefined) {
assertEquals(undefined, coverage);
@@ -74,7 +70,7 @@ TestCoverage(
(function f() {})();
`,
`
-[(function f() {})();[1]]
+[([function f() {}](f:1))();](anonymous:1)
`
);
@@ -88,9 +84,9 @@ for (var i = 0; i < 10; i++) {
`,
`
[for (var i = 0; i < 10; i++) {
- let f = [1]][() => 1[5]][;
+ let f = [() => 1](f:5);
i += f();
-}[1]]
+}](anonymous:1)
`
);
« 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