Stryker

MutantRunResultMatcher.js - Stryker report

Summary

File Based on all code Based on code coverage
MutantRunResultMatcher.js
100%
63/63 100% 63/63

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 (56testResult.coverage) 7{
                    var coveredFile = testResult.coverage[mutant.filename];
                    if (89coveredFile) 10{
                        if (1112!smallestStatement) 13{
                            smallestStatement = _this.findSmallestCoveringStatement(mutant, coveredFile);
                        }
                        covered = 1415coveredFile.s[smallestStatement] > 0;
                    }
                }
                else 16{
                    covered = true;
                }
                if (1718covered) 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 (222324_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 (2728!originalLocation) 29{
            statementIsSmallestStatement = true;
        }
        else 30{
            var lineDifference = 31(32originalLocation.end.line - originalLocation.start.line) - (33newLocation.end.line - newLocation.start.line);
            var coversLessLines = 3435lineDifference > 0;
            var coversLessColumns = 3637lineDifference === 0 && 383940(41newLocation.start.column - originalLocation.start.column) + (42originalLocation.end.column - newLocation.end.column) > 0;
            if (434445coversLessLines || coversLessColumns) 46{
                statementIsSmallestStatement = true;
            }
        }
        return statementIsSmallestStatement;
    };
    MutantRunResultMatcher.prototype.statementCoversMutant = function (mutant, location) 47{
        var mutantIsAfterStart = 484950mutant.location.end.line > location.start.line ||
            (5152mutant.location.end.line === location.start.line && 5354mutant.location.end.column >= location.start.column);
        var mutantIsBeforeEnd = 555657mutant.location.start.line < location.end.line ||
            (5859mutant.location.start.line === location.end.line && 6061mutant.location.start.column <= location.end.column);
        return 62mutantIsAfterStart && mutantIsBeforeEnd;
    };
    return MutantRunResultMatcher;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = MutantRunResultMatcher;
//# sourceMappingURL=MutantRunResultMatcher.js.map