public override IEnumerable <Mutation> ApplyMutations(BinaryExpressionSyntax node) { if (KindsToMutate.ContainsKey(node.Kind())) { foreach (var mutationKind in KindsToMutate[node.Kind()]) { var nodeLeft = node.Left; if (node.Kind() is SyntaxKind.AddExpression) { yield return(new Mutation { OriginalNode = node, ReplacementNode = nodeLeft, DisplayName = $"Arithmetic operator mutation - {node} replace with {nodeLeft}", Type = MutatorType.Arithmetic }); } else { var replacementNode = SyntaxFactory.BinaryExpression(mutationKind, nodeLeft, node.Right); replacementNode = replacementNode.WithOperatorToken(replacementNode.OperatorToken.WithTriviaFrom(node.OperatorToken)); yield return(new Mutation { OriginalNode = node, ReplacementNode = replacementNode, DisplayName = $"Arithmetic operator mutation - {node} replace with {replacementNode}", Type = MutatorType.Arithmetic }); } } } }
public override IEnumerable <Mutation> ApplyMutations(BinaryExpressionSyntax node) { if (KindsToMutate.ContainsKey(node.Kind())) { foreach (var mutationKind in KindsToMutate[node.Kind()]) { var nodeLeft = node.Left; var replacementNode = SyntaxFactory.BinaryExpression(mutationKind, nodeLeft, node.Right); replacementNode = replacementNode.WithOperatorToken(replacementNode.OperatorToken.WithTriviaFrom(node.OperatorToken)); yield return(new Mutation { OriginalNode = node, ReplacementNode = replacementNode, DisplayName = $"Bitwise operator mutation - {node} replace with {replacementNode}", Type = MutatorType.Bitwise }); } } else if (node.Kind() == SyntaxKind.ExclusiveOrExpression) { yield return(GetLogicalMutation(node)); yield return(GetIntegralMutation(node)); } }
public override IEnumerable <Mutation> ApplyMutations(LiteralExpressionSyntax node) { if (KindsToMutate.ContainsKey(node.Kind())) { var replacementNode = SyntaxFactory.LiteralExpression(KindsToMutate[node.Kind()]); yield return(new Mutation() { OriginalNode = node, ReplacementNode = replacementNode, DisplayName = $"Boolean mutation mutation - {node} replace with {replacementNode}", Type = MutatorType.Boolean }); } }