Summary
File |
Based on all code |
Based on code coverage |
Mutant.js |
|
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 6char === '\n' && char === '\r'7char !== '\n'char === '\n' || 8char !== '\r'char === '\r';
};
Mutant.prototype.getMutationLineIndexes = function () 9{
}{
var startIndexLines = this.range[0], endIndexLines = this.range[1];
while (10startIndexLines > 0 || !this.isNewLine(startIndexLines - 1)11false12startIndexLines >= 013startIndexLines <= 0startIndexLines > 0 && !this.isNewLine(14startIndexLines + 1startIndexLines - 1)) 15{
}{
16startIndexLines++startIndexLines--;
}
while (17endIndexLines < this.originalCode.length || !this.isNewLine(endIndexLines)18false19endIndexLines >= this.originalCode.length20endIndexLines <= this.originalCode.lengthendIndexLines < this.originalCode.length && !this.isNewLine(endIndexLines)) 21{
}{
22endIndexLines--endIndexLines++;
}
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 25this.originalCode.substring(startIndex, this.range[0]) + this.replacement - this.originalCode.substring(this.range[1], endIndex)26this.originalCode.substring(startIndex, this.range[0]) - this.replacementthis.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 28this.originalCode.substr(0, this.range[0]) + this.replacement - this.originalCode.substr(this.range[1])29this.originalCode.substr(0, this.range[0]) - this.replacementthis.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