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); |