Summary
Code
"use strict";
var MutantRunResultMatcher = (function () 0{
}{
function MutantRunResultMatcher(mutants, runResultsByTestId) 1{
}{
this.mutants = mutants;
this.runResultsByTestId = runResultsByTestId;
}
MutantRunResultMatcher.prototype.matchWithMutants = function () 2{
}{
var _this = this;
this.mutants.forEach(function (mutant) 3{
}{
var smallestStatement;
_this.runResultsByTestId.forEach(function (testResult, id) 4{
}{
var covered = false;
if (5true6falsetestResult.coverage) 7{
}{
var coveredFile = testResult.coverage[mutant.filename];
if (8true9falsecoveredFile) 10{
}{
if (11true12false!smallestStatement) 13{
}{
smallestStatement = _this.findSmallestCoveringStatement(mutant, coveredFile);
}
covered = 14coveredFile.s[smallestStatement] <= 015coveredFile.s[smallestStatement] >= 0coveredFile.s[smallestStatement] > 0;
}
}
else 16{
}{
covered = true;
}
if (17true18falsecovered) 19{
}{
mutant.addRunResultForTest(id, testResult);
}
});
});
};
MutantRunResultMatcher.prototype.findSmallestCoveringStatement = function (mutant, coveredFile) 20{
}{
var _this = this;
var smallestStatement;
Object.keys(coveredFile.statementMap).forEach(function (statementId) 21{
}{
var location = coveredFile.statementMap[statementId];
if (22_this.statementCoversMutant(mutant, location) || _this.isNewSmallestStatement(coveredFile.statementMap[smallestStatement], location)23true24false_this.statementCoversMutant(mutant, location) && _this.isNewSmallestStatement(coveredFile.statementMap[smallestStatement], location)) 25{
}{
smallestStatement = statementId;
}
});
return smallestStatement;
};
MutantRunResultMatcher.prototype.isNewSmallestStatement = function (originalLocation, newLocation) 26{
}{
var statementIsSmallestStatement = false;
if (27true28false!originalLocation) 29{
}{
statementIsSmallestStatement = true;
}
else 30{
}{
var lineDifference = 31originalLocation.end.line - originalLocation.start.line + (newLocation.end.line - newLocation.start.line)(32originalLocation.end.line + originalLocation.start.lineoriginalLocation.end.line - originalLocation.start.line) - (33newLocation.end.line + newLocation.start.linenewLocation.end.line - newLocation.start.line);
var coversLessLines = 34lineDifference <= 035lineDifference >= 0lineDifference > 0;
var coversLessColumns = 36lineDifference === 0 || newLocation.start.column - originalLocation.start.column + (originalLocation.end.column - newLocation.end.column) > 037lineDifference !== 0lineDifference === 0 && 38newLocation.start.column - originalLocation.start.column + (originalLocation.end.column - newLocation.end.column) <= 039newLocation.start.column - originalLocation.start.column + (originalLocation.end.column - newLocation.end.column) >= 040newLocation.start.column - originalLocation.start.column - (originalLocation.end.column - newLocation.end.column)(41newLocation.start.column + originalLocation.start.columnnewLocation.start.column - originalLocation.start.column) + (42originalLocation.end.column + newLocation.end.columnoriginalLocation.end.column - newLocation.end.column) > 0;
if (43true44false45coversLessLines && coversLessColumnscoversLessLines || coversLessColumns) 46{
}{
statementIsSmallestStatement = true;
}
}
return statementIsSmallestStatement;
};
MutantRunResultMatcher.prototype.statementCoversMutant = function (mutant, location) 47{
}{
var mutantIsAfterStart = 48mutant.location.end.line > location.start.line && (mutant.location.end.line === location.start.line && mutant.location.end.column >= location.start.column)49mutant.location.end.line <= location.start.line50mutant.location.end.line >= location.start.linemutant.location.end.line > location.start.line ||
(51mutant.location.end.line === location.start.line || mutant.location.end.column >= location.start.column52mutant.location.end.line !== location.start.linemutant.location.end.line === location.start.line && 53mutant.location.end.column < location.start.column54mutant.location.end.column > location.start.columnmutant.location.end.column >= location.start.column);
var mutantIsBeforeEnd = 55mutant.location.start.line < location.end.line && (mutant.location.start.line === location.end.line && mutant.location.start.column <= location.end.column)56mutant.location.start.line >= location.end.line57mutant.location.start.line <= location.end.linemutant.location.start.line < location.end.line ||
(58mutant.location.start.line === location.end.line || mutant.location.start.column <= location.end.column59mutant.location.start.line !== location.end.linemutant.location.start.line === location.end.line && 60mutant.location.start.column > location.end.column61mutant.location.start.column < location.end.columnmutant.location.start.column <= location.end.column);
return 62mutantIsAfterStart || mutantIsBeforeEndmutantIsAfterStart && mutantIsBeforeEnd;
};
return MutantRunResultMatcher;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = MutantRunResultMatcher;
//# sourceMappingURL=MutantRunResultMatcher.js.map