UNPKG

apex-mutation-testing

Version:

Apex mutation testing plugin

37 lines 1.2 kB
import { BaseListener } from './baseListener.js'; import { TerminalNode } from 'antlr4ts/tree/index.js'; export class IncrementMutator extends BaseListener { REPLACEMENT_MAP = { '++': '--', '--': '++', }; // Target rule // expression : // | expression ('++' | '--') // | ('+' | '-' | '++' | '--') expression enterPostOpExpression(ctx) { this.processOperation(ctx); } enterPreOpExpression(ctx) { this.processOperation(ctx); } processOperation(ctx) { if (ctx.childCount === 2) { let symbol = null; if (ctx.getChild(0) instanceof TerminalNode) { symbol = ctx.getChild(0); } else if (ctx.getChild(1) instanceof TerminalNode) { symbol = ctx.getChild(1); } if (symbol !== null && symbol.text in this.REPLACEMENT_MAP) { this._mutations.push({ mutationName: this.constructor.name, token: symbol, replacement: this.REPLACEMENT_MAP[symbol.text], }); } } } } //# sourceMappingURL=incrementMutator.js.map