Stryker

Mutant.js - Stryker report

Summary

File
Mutation score
# Killed
# Survived
# Timeout
# No coverage
# Errors
Total detected
Total undetected
Total mutants
Mutant.js
84%
27/32 23 5 4 0 0 27 5 32

Code

"use strict";
var StrykerTempFolder_1 = require('./utils/StrykerTempFolder');
/**
 * Represents a mutation which has been applied to a file.
 */
var Mutant = (function () 0{
    /**
     * @param mutatorName - The name of the Mutator which created this mutant.
     * @param filename - The name of the file which was mutated, including the path.
     * @param originalCode - The original content of the file which has not been mutated.
     * @param replacement - The mutated code which will replace a part of the originalCode.
     * @param location - The location of the code to be mutated - line and column based
     * @param range - The location of the code to be mutated - index based
     */
    function Mutant(mutatorName, filename, originalCode, replacement, location, range) 1{
        this.mutatorName = mutatorName;
        this.filename = filename;
        this.originalCode = originalCode;
        this.replacement = replacement;
        this.location = location;
        this.range = range;
        this._scopedTestIds = [];
        this.specsRan = [];
        this._timeSpentScopedTests = 0;
    }
    Object.defineProperty(Mutant.prototype, "scopedTestIds", {
        get: function () 2{
            return this._scopedTestIds;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Mutant.prototype, "timeSpentScopedTests", {
        get: function () 3{
            return this._timeSpentScopedTests;
        },
        enumerable: true,
        configurable: true
    });
    Mutant.prototype.addTestResult = function (index, testResult) 4{
        this._scopedTestIds.push(index);
        this._timeSpentScopedTests += testResult.timeSpentMs;
    };
    Mutant.prototype.isNewLine = function (index) 5{
        var char = this.originalCode[index];
        return 67char === '\n' || 8char === '\r';
    };
    Mutant.prototype.getMutationLineIndexes = function () 9{
        var startIndexLines = this.range[0], endIndexLines = this.range[1];
        while (10111213startIndexLines > 0 && !this.isNewLine(14startIndexLines - 1)) 15{
            16startIndexLines--;
        }
        while (17181920endIndexLines < this.originalCode.length && !this.isNewLine(endIndexLines)) 21{
            22endIndexLines++;
        }
        return [startIndexLines, endIndexLines];
    };
    Object.defineProperty(Mutant.prototype, "originalLines", {
        get: function () 23{
            var _a = this.getMutationLineIndexes(), startIndex = _a[0], endIndex = _a[1];
            return this.originalCode.substring(startIndex, endIndex);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Mutant.prototype, "mutatedLines", {
        get: function () 24{
            var _a = this.getMutationLineIndexes(), startIndex = _a[0], endIndex = _a[1];
            return 2526this.originalCode.substring(startIndex, this.range[0]) + this.replacement + this.originalCode.substring(this.range[1], endIndex);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Mutant.prototype, "mutatedCode", {
        get: function () 27{
            return 2829this.originalCode.substr(0, this.range[0]) + this.replacement + this.originalCode.substr(this.range[1]);
        },
        enumerable: true,
        configurable: true
    });
    /**
     * Saves the mutated code in a mutated file.
     * @function
     */
    Mutant.prototype.save = function (filename) 30{
        return StrykerTempFolder_1.default.writeFile(filename, this.mutatedCode);
    };
    ;
    /**
     * Removes the mutated file.
     * @function
     */
    Mutant.prototype.reset = function (filename) 31{
        return StrykerTempFolder_1.default.writeFile(filename, this.originalCode);
    };
    ;
    return Mutant;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Mutant;
//# sourceMappingURL=Mutant.js.map