public void ReplaceCloneValue() { const string code = @"int ione ione = 5 int itwo int ithree ithree = 2 int ifour itwo = ione stop"; const int indexToReplace = 6; var commandToReplace = new CloneValue("ifour", "ithree"); var commands = GenerateCommands(code); var mutation = GetMutationForCloneValue(commands, indexToReplace, commandToReplace); mutation.Transform(); const string resultCode = @"int ione ione = 5 int itwo int ithree ithree = 2 int ifour ifour = ithree stop"; var resultCommands = GenerateCommands(resultCode); Assert.IsTrue(AreCollectionsEquals(commands, resultCommands)); }
public void Accept(CloneValue command) { if (!_conditions.Peek()) return; var value = _variables[command.SourceName]; _variables[command.TargetName] = value; }
public void Accept(CloneValue command) { if (!_variables.ContainsKey(command.SourceName) || !_variables.ContainsKey(command.TargetName) || _variables[command.SourceName]==null) { _isExecutable = false; return; } var value = _variables[command.SourceName]; _variables[command.TargetName] = value; }
public void AddCloneValue() { const string code = @"int ione ione = 5 int itwo"; const int indexToAdd = 3; var commandToAdd = new CloneValue("itwo", "ione"); var commands = GenerateCommands(code); var mutation = GetMutationForCloneValue(commands, commandToAdd, indexToAdd); mutation.Transform(); const string resultCode = @"int ione ione = 5 int itwo itwo = ione"; var resultCommands = GenerateCommands(resultCode); Assert.IsTrue(AreCollectionsEquals(commands, resultCommands)); }
public void Accept(CloneValue command) { _builder.AppendLine($"{command.TargetName} = {command.SourceName}"); }
private AddCommandMutation GetMutationForCloneValue(ICommandsList commands, CloneValue command, int indexToAdd) { var random = new AddRandom(); var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands); var sourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SourceName, commands); random.TuneCloneValue(targetDeclarationIndex, sourceDeclarationIndex, indexToAdd); return new AddCommandMutation(random, commands); }
public void Accept(CloneValue command) { var comparableCommand = _second as CloneValue; _isEqual = command.TargetName == comparableCommand.TargetName && command.SourceName == comparableCommand.SourceName; }
private ReplaceCommandMutation GetMutationForCloneValue(ICommandsList commands, int replaceIndex, CloneValue command) { var random = new ReplaceRandom(); var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands); var sourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SourceName, commands); random.TuneCloneValue(replaceIndex, targetDeclarationIndex, sourceDeclarationIndex); return new ReplaceCommandMutation(random, commands); }