stryker
Version:
The extendable JavaScript mutation testing framework
43 lines • 1.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var esprima_1 = require("esprima");
var BinaryOperatorMutator = /** @class */ (function () {
function BinaryOperatorMutator() {
this.name = 'BinaryOperator';
this.type = esprima_1.Syntax.BinaryExpression;
this.operators = {
'!=': '==',
'!==': '===',
'%': '*',
'*': '/',
'+': '-',
'-': '+',
'/': '*',
'<': ['<=', '>='],
'<=': ['<', '>'],
'==': '!=',
'===': '!==',
'>': ['>=', '<='],
'>=': ['>', '<']
};
}
BinaryOperatorMutator.prototype.applyMutations = function (node, copy) {
var nodes = [];
if (node.type === this.type && this.operators[node.operator]) {
var binaryNode_1 = node;
var mutatedOperators = this.operators[node.operator];
if (typeof mutatedOperators === 'string') {
mutatedOperators = [mutatedOperators];
}
mutatedOperators.forEach(function (operator) {
var mutatedNode = copy(binaryNode_1);
mutatedNode.operator = operator;
nodes.push(mutatedNode);
});
}
return nodes;
};
return BinaryOperatorMutator;
}());
exports.default = BinaryOperatorMutator;
//# sourceMappingURL=BinaryOperatorMutator.js.map