OLD | NEW |
(Empty) | |
| 1 <html> |
| 2 <head> |
| 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
| 4 <script> |
| 5 function initialize_SegmentsMerge() { |
| 6 |
| 7 InspectorTest.preloadModule("coverage"); |
| 8 |
| 9 } |
| 10 |
| 11 function test() |
| 12 { |
| 13 testAndDump([], []); |
| 14 testAndDump([{end: 10, count: 1, depth: 1}], []); |
| 15 testAndDump([{end: 10, count: 1, depth: 1}], [{end: 10, count: 1, depth: 1}]
); |
| 16 testAndDump([{end: 10, count: 1, depth: 1}], [{end: 20, count: 1, depth: 1}]
); |
| 17 testAndDump([{end: 10, count: 1, depth: 1}, {end: 20, count: 1, depth: 1}],
[]); |
| 18 testAndDump([{end: 30, count: 1, depth: 1}], [{end: 10, count: undefined, de
pth: 0}, {end: 20, count: 2, depth: 1}]); |
| 19 testAndDump([{end: 30, count: undefined, depth: 0}], [{end: 10, count: undef
ined, depth: 0}, {end: 20, count: 2, depth: 1}]); |
| 20 |
| 21 InspectorTest.completeTest(); |
| 22 |
| 23 function testAndDump(a, b) |
| 24 { |
| 25 dumpSegments("A: ", a); |
| 26 dumpSegments("B: ", b); |
| 27 |
| 28 var mergedAB = Coverage.CoverageInfo._mergeCoverage(a, b); |
| 29 dumpSegments("merged: ", mergedAB); |
| 30 var mergedBA = Coverage.CoverageInfo._mergeCoverage(b, a); |
| 31 if (!rangesEqual(mergedAB, mergedBA)) |
| 32 dumpSegments("FAIL, merge(b, a) != merge(a, b): ", mergedBA); |
| 33 } |
| 34 |
| 35 function dumpSegments(prefix, arr) |
| 36 { |
| 37 InspectorTest.addResult((prefix || "") + JSON.stringify(arr)); |
| 38 } |
| 39 |
| 40 function rangesEqual(a, b) |
| 41 { |
| 42 if (a.length !== b.length) |
| 43 return false; |
| 44 |
| 45 for (var i = 0; i < a.length; i++) { |
| 46 if (a[i].end !== b[i].end) |
| 47 return false; |
| 48 if (a[i].count !== b[i].count) |
| 49 return false; |
| 50 if (a[i].depth !== b[i].depth) |
| 51 return false; |
| 52 } |
| 53 return true; |
| 54 } |
| 55 } |
| 56 |
| 57 </script> |
| 58 </head> |
| 59 |
| 60 <body onload="runTest()"> |
| 61 <p>Tests the merge of disjoint segment lists in CoverageModel.</p> |
| 62 |
| 63 </body> |
| 64 </html> |
OLD | NEW |