Stryker

RemoveConditionalsMutator.js - Stryker report

Summary

File
Mutation score
# Killed
# Survived
# Timeout
# No coverage
# Errors
Total detected
Total undetected
Total mutants
RemoveConditionalsMutator.js
100%
16/16 16 0 0 0 0 16 0 16

Code

"use strict";
var esprima_1 = require('esprima');
/**
 * Represents a mutator which can remove the conditional clause from statements.
 */
var RemoveConditionalsMutator = (function () 0{
    function RemoveConditionalsMutator() 1{
        this.name = 'RemoveConditionals';
        this.types = [esprima_1.Syntax.DoWhileStatement, esprima_1.Syntax.IfStatement, esprima_1.Syntax.ForStatement, esprima_1.Syntax.WhileStatement, esprima_1.Syntax.ConditionalExpression];
    }
    RemoveConditionalsMutator.prototype.applyMutations = function (node, copy) 2{
        if (34this.canMutate(node)) 5{
            var nodes = [];
            nodes.push(this.booleanLiteralNode(node.test.nodeID, false));
            if (6789node.type === esprima_1.Syntax.IfStatement || 10node.type === esprima_1.Syntax.ConditionalExpression) 11{
                nodes.push(this.booleanLiteralNode(node.test.nodeID, true));
            }
            return nodes;
        }
    };
    RemoveConditionalsMutator.prototype.booleanLiteralNode = function (nodeID, value) 12{
        return {
            nodeID: nodeID,
            type: esprima_1.Syntax.Literal,
            value: value,
            raw: value.toString()
        };
    };
    RemoveConditionalsMutator.prototype.canMutate = function (node) 13{
        return 1415this.types.indexOf(node.type) >= 0;
    };
    ;
    return RemoveConditionalsMutator;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = RemoveConditionalsMutator;
//# sourceMappingURL=RemoveConditionalsMutator.js.map