File |
Mutation score |
# Killed |
# Survived |
# Timeout |
# No coverage |
# Errors |
Total detected |
Total undetected |
Total mutants |
|
---|---|---|---|---|---|---|---|---|---|---|
MutantTestMatcher.js |
|
58/75 | 58 | 17 | 0 | 0 | 0 | 58 | 17 | 75 |
"use strict";
var MutantTestMatcher = (function () 0{
}{
function MutantTestMatcher(mutants, initialRunResult, statementMaps, options) 1{
}{
this.mutants = mutants;
this.initialRunResult = initialRunResult;
this.statementMaps = statementMaps;
this.options = options;
}
MutantTestMatcher.prototype.matchWithMutants = function () 2{
}{
var _this = this;
this.mutants.forEach(function (mutant) 3{
}{
var statementMap = _this.statementMaps[mutant.filename];
var smallestStatement = _this.findSmallestCoveringStatement(mutant, statementMap);
_this.initialRunResult.tests.forEach(function (testResult, id) 4{
}{
var covered = false;
var coverageCollection = _this.findCoverageCollectionForTest(id);
if (5false6true7coverageCollection || smallestStatementcoverageCollection && smallestStatement) 8{
}{
var coveredFile = coverageCollection[mutant.filename];
if (9true10falsecoveredFile) 11{
}{
covered = 12coveredFile.s[smallestStatement] >= 013coveredFile.s[smallestStatement] <= 0coveredFile.s[smallestStatement] > 0;
}
}
else 14{
}{
// If there is no coverage data we have to assume that the test covers the mutant
covered = true;
}
if (15false16truecovered) 17{
}{
mutant.addTestResult(id, testResult);
}
});
});
};
/**
* Finds the smallest statement that covers a mutant.
* @param mutant The mutant.
* @param statementMap of the covering file.
* @returns The index of the coveredFile which contains the smallest statement surrounding the mutant.
*/
MutantTestMatcher.prototype.findSmallestCoveringStatement = function (mutant, statementMap) 18{
}{
var _this = this;
var smallestStatement = null;
if (19false20truestatementMap) 21{
}{
Object.keys(statementMap).forEach(function (statementId) 22{
}{
var location = statementMap[statementId];
if (23_this.statementCoversMutant(mutant.location, location) || _this.isNewSmallestStatement(statementMap[smallestStatement], location)24true25false_this.statementCoversMutant(mutant.location, location) && _this.isNewSmallestStatement(statementMap[smallestStatement], location)) 26{
}{
smallestStatement = statementId;
}
});
}
return smallestStatement;
};
/**
* Indicates whether a statement is the smallest statement of the two statements provided.
* @param originalLocation The area which may cover a bigger area than the newLocation.
* @param newLocation The area which may cover a smaller area than the originalLocation.
* @returns true if the newLocation covers a smaller area than the originalLocation, making it the smaller statement.
*/
MutantTestMatcher.prototype.isNewSmallestStatement = function (originalLocation, newLocation) 27{
}{
var statementIsSmallestStatement = false;
if (28false29true!originalLocation) 30{
}{
statementIsSmallestStatement = true;
}
else 31{
}{
var lineDifference = 32originalLocation.end.line - originalLocation.start.line + (newLocation.end.line - newLocation.start.line)(33originalLocation.end.line + originalLocation.start.lineoriginalLocation.end.line - originalLocation.start.line) - (34newLocation.end.line + newLocation.start.linenewLocation.end.line - newLocation.start.line);
var coversLessLines = 35lineDifference >= 036lineDifference <= 0lineDifference > 0;
var coversLessColumns = 37lineDifference === 0 || newLocation.start.column - originalLocation.start.column + (originalLocation.end.column - newLocation.end.column) > 038lineDifference !== 0lineDifference === 0 && 39newLocation.start.column - originalLocation.start.column + (originalLocation.end.column - newLocation.end.column) >= 040newLocation.start.column - originalLocation.start.column + (originalLocation.end.column - newLocation.end.column) <= 041newLocation.start.column - originalLocation.start.column - (originalLocation.end.column - newLocation.end.column)(42newLocation.start.column + originalLocation.start.columnnewLocation.start.column - originalLocation.start.column) + (43originalLocation.end.column + newLocation.end.columnoriginalLocation.end.column - newLocation.end.column) > 0;
if (44false45true46coversLessLines && coversLessColumnscoversLessLines || coversLessColumns) 47{
}{
statementIsSmallestStatement = true;
}
}
return statementIsSmallestStatement;
};
/**
* Indicates whether a statement covers a mutant.
* @param mutantLocation The location of the mutant.
* @param statementLocation The location of the statement.
* @returns true if the statment covers the mutant.
*/
MutantTestMatcher.prototype.statementCoversMutant = function (mutantLocation, statementLocation) 48{
}{
var mutantIsAfterStart = 49mutantLocation.start.line > statementLocation.start.line && (mutantLocation.start.line === statementLocation.start.line && mutantLocation.start.column >= statementLocation.start.column)50mutantLocation.start.line >= statementLocation.start.line51mutantLocation.start.line <= statementLocation.start.linemutantLocation.start.line > statementLocation.start.line ||
(52mutantLocation.start.line === statementLocation.start.line || mutantLocation.start.column >= statementLocation.start.column53mutantLocation.start.line !== statementLocation.start.linemutantLocation.start.line === statementLocation.start.line && 54mutantLocation.start.column > statementLocation.start.column55mutantLocation.start.column < statementLocation.start.columnmutantLocation.start.column >= statementLocation.start.column);
var mutantIsBeforeEnd = 56mutantLocation.end.line < statementLocation.end.line && (mutantLocation.end.line === statementLocation.end.line && mutantLocation.end.column <= statementLocation.end.column)57mutantLocation.end.line <= statementLocation.end.line58mutantLocation.end.line >= statementLocation.end.linemutantLocation.end.line < statementLocation.end.line ||
(59mutantLocation.end.line === statementLocation.end.line || mutantLocation.end.column <= statementLocation.end.column60mutantLocation.end.line !== statementLocation.end.linemutantLocation.end.line === statementLocation.end.line && 61mutantLocation.end.column < statementLocation.end.column62mutantLocation.end.column > statementLocation.end.columnmutantLocation.end.column <= statementLocation.end.column);
return 63mutantIsAfterStart || mutantIsBeforeEndmutantIsAfterStart && mutantIsBeforeEnd;
};
MutantTestMatcher.prototype.findCoverageCollectionForTest = function (testId) 64{
}{
if (65false66truethis.initialRunResult.coverage) 67{
}{
if (68false69truethis.isCoverageCollectionPerTest(this.initialRunResult.coverage)) 70{
}{
return this.initialRunResult.coverage[testId];
}
else 71{
}{
return this.initialRunResult.coverage;
}
}
else 72{
}{
return null;
}
};
MutantTestMatcher.prototype.isCoverageCollectionPerTest = function (coverage) 73{
}{
return 74this.options.coverageAnalysis !== 'perTest'this.options.coverageAnalysis === 'perTest';
};
return MutantTestMatcher;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = MutantTestMatcher;
//# sourceMappingURL=MutantTestMatcher.js.map