UNPKG

stryker

Version:
27 lines 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var esprima_1 = require("esprima"); var BooleanSubstitutionMutator = /** @class */ (function () { function BooleanSubstitutionMutator() { this.name = 'BooleanSubstitution'; } BooleanSubstitutionMutator.prototype.applyMutations = function (node, copy) { var nodes = []; // !a -> a if (node.type === esprima_1.Syntax.UnaryExpression && node.operator === '!') { var mutatedNode = copy(node.argument); mutatedNode.nodeID = node.nodeID; nodes.push(mutatedNode); } // true -> false or false -> true if (node.type === esprima_1.Syntax.Literal && typeof node.value === 'boolean') { var mutatedNode = copy(node); mutatedNode.value = !mutatedNode.value; nodes.push(mutatedNode); } return nodes; }; return BooleanSubstitutionMutator; }()); exports.default = BooleanSubstitutionMutator; //# sourceMappingURL=BooleanSubstitutionMutator.js.map