public void Accept(Print command) { _builder.AppendLine($"print {command.Variable}"); }
private AddCommandMutation GetMutationForPrint(ICommandsList commands, Print command, int indexToAdd) { var random = new AddRandom(); var declarationIndex = GetDeclarationIndexOfVariable(command.Variable, commands); random.TunePrint(declarationIndex, indexToAdd); return new AddCommandMutation(random, commands); }
public void Accept(Print command) { if (!_conditions.Peek()) return; var value = _variables[command.Variable]; _console.AppendLine(value.ToString()); }
public void AddPrint() { const string code = @"int ione ione = 5 int itwo itwo = 2"; const int indexToAdd = 4; var commandToAdd = new Print("itwo"); var commands = GenerateCommands(code); var mutation = GetMutationForPrint(commands, commandToAdd, indexToAdd); mutation.Transform(); const string resultCode = @"int ione ione = 5 int itwo itwo = 2 print itwo"; var resultCommands = GenerateCommands(resultCode); Assert.IsTrue(AreCollectionsEquals(commands, resultCommands)); }
public void Accept(Print command) { _isEqual = command.Variable == (_second as Print).Variable; }
private ReplaceCommandMutation GetMutationForPrint(ICommandsList commands, int replaceIndex, Print command) { var random = new ReplaceRandom(); var declarationIndex = GetDeclarationIndexOfVariable(command.Variable, commands); random.TunePrint(replaceIndex, declarationIndex); return new ReplaceCommandMutation(random, commands); }
public void ReplacePrint() { const string code = @"int ione ione = 5 int itwo int ithree ithree = ione print ithree"; const int indexToReplace = 5; var commandToReplace = new Print("ione"); var commands = GenerateCommands(code); var mutation = GetMutationForPrint(commands, indexToReplace, commandToReplace); mutation.Transform(); const string resultCode = @"int ione ione = 5 int itwo int ithree ithree = ione print ione"; var resultCommands = GenerateCommands(resultCode); Assert.IsTrue(AreCollectionsEquals(commands, resultCommands)); }
public void Accept(Print command) { if (!_variables.ContainsKey(command.Variable) || _variables[command.Variable]==null) { _isExecutable = false; return; } var value = _variables[command.Variable]; _console.AppendLine(value.ToString()); }