Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Instrumenter from '../../src/instrumenter';
import {classes} from 'istanbul-lib-coverage';
import {assert} from 'chai';
import clone from 'clone';
import readInitialCoverage from '../../src/read-coverage';
var FileCoverage = classes.FileCoverage;
function pad(str, len) {
var blanks = ' ';
if (str.length >= len) {
return str;
}
return blanks.substring(0, len - str.length) + str;
}
function annotatedCode(code) {
var codeArray = code.split('\n'),
line = 0,
annotated = codeArray.map(function (str) {
line += 1;
return pad(line, 6) + ': ' + str;
});
line: loc && loc.end.line,
column: loc && loc.end.column
}
};
}
/**
* SourceCoverage provides mutation methods to manipulate the structure of
* a file coverage object. Used by the instrumenter to create a full coverage
* object for a file incrementally.
*
* @private
* @param pathOrObj {String|Object} - see the argument for {@link FileCoverage}
* @extends FileCoverage
* @constructor
*/
class SourceCoverage extends classes.FileCoverage {
constructor(pathOrObj) {
super(pathOrObj);
this.meta = {
last: {
s: 0,
f: 0,
b: 0
}
};
}
newStatement(loc) {
const s = this.meta.last.s;
this.data.statementMap[s] = cloneLocation(loc);
this.data.s[s] = 0;
this.meta.last.s += 1;