File |
Mutation score |
# Killed |
# Survived |
# Timeout |
# No coverage |
# Errors |
Total detected |
Total undetected |
Total mutants |
|
---|---|---|---|---|---|---|---|---|---|---|
Mutant.js |
|
27/32 | 23 | 5 | 4 | 0 | 0 | 27 | 5 | 32 |
"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 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 (10false11startIndexLines > 0 || !this.isNewLine(startIndexLines - 1)12startIndexLines >= 013startIndexLines <= 0startIndexLines > 0 && !this.isNewLine(14startIndexLines + 1startIndexLines - 1)) 15{
}{
16startIndexLines++startIndexLines--;
}
while (17false18endIndexLines < this.originalCode.length || !this.isNewLine(endIndexLines)19endIndexLines <= 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
});
/**
* 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