Stryker

Mutant.js - Stryker report

Summary

File Based on all code Based on code coverage
Mutant.js
100%
32/32 100% 32/32

Code

"use strict";
var StrykerTempFolder_1 = require('./utils/StrykerTempFolder');
var Mutant = (function () 0{
    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.scopedTestsById = [];
        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.addRunResultForTest = function (index, runResult) 4{
        this._scopedTestIds.push(index);
        this._timeSpentScopedTests += runResult.timeSpent;
        this.scopedTestsById[index] = runResult;
    };
    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
    });
    Mutant.prototype.save = function (filename) 30{
        return StrykerTempFolder_1.default.writeFile(filename, this.mutatedCode);
    };
    ;
    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